Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @login_required
- def logout_student(request):
- logout(request)
- # Redirect to a success page.
- return HttpResponseRedirect('/index/')
- def logout(request):
- """
- Removes the authenticated user's ID from the request and flushes their
- session data.
- """
- # Dispatch the signal before the user is logged out so the receivers have a
- # chance to find out *who* logged out.
- user = getattr(request, 'user', None)
- if hasattr(user, 'is_authenticated') and not user.is_authenticated():
- user = None
- user_logged_out.send(sender=user.__class__, request=request, user=user)
- request.session.flush()
- if hasattr(request, 'user'):
- from django.contrib.auth.models import AnonymousUser
- request.user = AnonymousUser()
- def delete(self, session_key=None):
- if session_key is None:
- if self.session_key is None:
- return
- session_key = self.session_key
- try:
- Session.objects.get(session_key=session_key).delete()
- except Session.DoesNotExist:
- pass
Add Comment
Please, Sign In to add comment