Remove the authenticated user's ID from the request and flush their session data.
(request)
| 220 | |
| 221 | |
| 222 | def logout(request): |
| 223 | """ |
| 224 | Remove the authenticated user's ID from the request and flush their session |
| 225 | data. |
| 226 | """ |
| 227 | # Dispatch the signal before the user is logged out so the receivers have a |
| 228 | # chance to find out *who* logged out. |
| 229 | user = getattr(request, "user", None) |
| 230 | if not getattr(user, "is_authenticated", True): |
| 231 | user = None |
| 232 | user_logged_out.send(sender=user.__class__, request=request, user=user) |
| 233 | request.session.flush() |
| 234 | if hasattr(request, "user"): |
| 235 | from django.contrib.auth.models import AnonymousUser |
| 236 | |
| 237 | request.user = AnonymousUser() |
| 238 | |
| 239 | |
| 240 | async def alogout(request): |
no test coverage detected