Ticket #5612: login_logout_signals-2.diff
File login_logout_signals-2.diff, 1.4 KB (added by , 17 years ago) |
---|
-
django/contrib/auth/__init__.py
1 1 import datetime 2 2 from django.core.exceptions import ImproperlyConfigured 3 from django.contrib.auth import signals 4 from django.dispatch import dispatcher 3 5 6 4 7 SESSION_KEY = '_auth_user_id' 5 8 BACKEND_SESSION_KEY = '_auth_user_backend' 6 9 REDIRECT_FIELD_NAME = 'next' … … 57 60 request.session[BACKEND_SESSION_KEY] = user.backend 58 61 if hasattr(request, 'user'): 59 62 request.user = user 63 dispatcher.send(signal=signals.user_logged_in, request=request) 60 64 61 65 def logout(request): 62 66 """ … … 71 75 except KeyError: 72 76 pass 73 77 if hasattr(request, 'user'): 78 # Dispatch the signal before it is reset to AnonymousUser so 79 # the receivers have a chance to find out *who* logged out 80 dispatcher.send(signal=signals.user_logged_out, request=request) 74 81 from django.contrib.auth.models import AnonymousUser 75 82 request.user = AnonymousUser() 76 83 -
django/contrib/auth/signals.py
1 2 user_logged_in = object() 3 user_logged_out = object()