Ticket #5612: login_logout_signals-2.diff

File login_logout_signals-2.diff, 1.4 KB (added by Peter van Kampen, 17 years ago)

Self contained (moved signals to contrib.auth.signals)

  • django/contrib/auth/__init__.py

     
    11import datetime
    22from django.core.exceptions import ImproperlyConfigured
     3from django.contrib.auth import signals
     4from django.dispatch import dispatcher
    35
     6
    47SESSION_KEY = '_auth_user_id'
    58BACKEND_SESSION_KEY = '_auth_user_backend'
    69REDIRECT_FIELD_NAME = 'next'
     
    5760    request.session[BACKEND_SESSION_KEY] = user.backend
    5861    if hasattr(request, 'user'):
    5962        request.user = user
     63    dispatcher.send(signal=signals.user_logged_in, request=request)
    6064
    6165def logout(request):
    6266    """
     
    7175    except KeyError:
    7276        pass
    7377    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)
    7481        from django.contrib.auth.models import AnonymousUser
    7582        request.user = AnonymousUser()
    7683
  • django/contrib/auth/signals.py

     
     1
     2user_logged_in = object()
     3user_logged_out = object()
Back to Top