Ticket #5612: login_logout_signals_r10823.diff
File login_logout_signals_r10823.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/__init__.py
1 1 import datetime 2 2 from django.core.exceptions import ImproperlyConfigured 3 3 from django.utils.importlib import import_module 4 from django.contrib.auth import signals 4 5 5 6 SESSION_KEY = '_auth_user_id' 6 7 BACKEND_SESSION_KEY = '_auth_user_backend' … … 52 53 if user is None: 53 54 user = request.user 54 55 # TODO: It would be nice to support different login methods, like signed cookies. 56 signals.user_logged_in.send(sender=None, request=request, user=user) 55 57 user.last_login = datetime.datetime.now() 56 58 user.save() 57 59 … … 75 77 """ 76 78 request.session.flush() 77 79 if hasattr(request, 'user'): 80 # Dispatch the signal before it is reset to AnonymousUser so 81 # the receivers have a chance to find out *who* logged out 82 signals.user_logged_out.send(sender=None, request=request) 78 83 from django.contrib.auth.models import AnonymousUser 79 84 request.user = AnonymousUser() 80 85 -
django/contrib/auth/signals.py
1 import django.dispatch 2 3 user_logged_in = django.dispatch.Signal(providing_args=['request', 'user']) 4 user_logged_out = django.dispatch.Signal(providing_args=['request',]) 5 No newline at end of file