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