Spaces:
Build error
Build error
Merge pull request #78 from DL4DS/bug_fix
Browse files- code/app.py +5 -2
code/app.py
CHANGED
@@ -94,10 +94,13 @@ async def get_user_info_from_cookie(request: Request):
|
|
94 |
|
95 |
|
96 |
async def del_user_info_from_cookie(request: Request, response: Response):
|
|
|
97 |
response.delete_cookie("X-User-Info")
|
98 |
response.delete_cookie("session_token")
|
|
|
99 |
session_token = request.cookies.get("session_token")
|
100 |
-
if
|
|
|
101 |
del session_store[session_token]
|
102 |
|
103 |
|
@@ -191,7 +194,7 @@ async def auth_google(request: Request):
|
|
191 |
response = RedirectResponse(url="/post-signin", status_code=303)
|
192 |
response.set_cookie(key="session_token", value=session_token)
|
193 |
response.set_cookie(
|
194 |
-
key="X-User-Info", value=user_info_encoded
|
195 |
) # TODO: is the flag httponly=True necessary?
|
196 |
return response
|
197 |
except Exception as e:
|
|
|
94 |
|
95 |
|
96 |
async def del_user_info_from_cookie(request: Request, response: Response):
|
97 |
+
# Delete cookies from the response
|
98 |
response.delete_cookie("X-User-Info")
|
99 |
response.delete_cookie("session_token")
|
100 |
+
# Get the session token from the request cookies
|
101 |
session_token = request.cookies.get("session_token")
|
102 |
+
# Check if the session token exists in the session_store before deleting
|
103 |
+
if session_token and session_token in session_store:
|
104 |
del session_store[session_token]
|
105 |
|
106 |
|
|
|
194 |
response = RedirectResponse(url="/post-signin", status_code=303)
|
195 |
response.set_cookie(key="session_token", value=session_token)
|
196 |
response.set_cookie(
|
197 |
+
key="X-User-Info", value=user_info_encoded, httponly=True
|
198 |
) # TODO: is the flag httponly=True necessary?
|
199 |
return response
|
200 |
except Exception as e:
|