MCPcopy
hub / github.com/django/django / logout

Function logout

django/contrib/auth/__init__.py:222–237  ·  view source on GitHub ↗

Remove the authenticated user's ID from the request and flush their session data.

(request)

Source from the content-addressed store, hash-verified

220
221
222def 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
240async def alogout(request):

Callers 1

logoutMethod · 0.90

Calls 3

AnonymousUserClass · 0.85
sendMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected