Skip to content

Commit f2b7aed

Browse files
committed
Correct logout with an expiring token instead of deleting it
1 parent 33d3d05 commit f2b7aed

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

WS/api/views.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ class LogoutView(APIView):
102102
def post(self, request):
103103
logger.info(f"[Logout] Cookies reçus pour suppression : {request.COOKIES}")
104104
response = Response({"detail": "Déconnecté."}, status=status.HTTP_200_OK)
105-
deletion_keys = ["path", "domain"]
106-
cookie_params_delete = {
107-
k: v for k, v in COOKIE_PARAMS.items() if k in deletion_keys
108-
}
109-
response.delete_cookie("access_token", **cookie_params_delete)
110-
response.delete_cookie("refresh_token", **cookie_params_delete)
105+
106+
for cookie in ["access_token", "refresh_token"]:
107+
response.set_cookie(
108+
key=cookie,
109+
value="",
110+
max_age=0,
111+
**COOKIE_PARAMS,
112+
)
111113
return response
112114

113115

WS/next_shape_ws/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def get_cookie_settings():
226226
"path": "/",
227227
}
228228
else:
229-
return {"httponly": True, "secure": True, "samesite": "None", "path": "/"}
229+
return {"httponly": True, "secure": False, "samesite": "Lax", "path": "/"}
230230

231231

232232
COOKIE_PARAMS = get_cookie_settings()

0 commit comments

Comments
 (0)