1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #5612 -- Added login and logout signals to contrib auth app. Thanks SmileyChris and pterk.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14710 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel
2010-11-26 13:33:27 +00:00
parent 81323cb119
commit 132afbf8ee
7 changed files with 112 additions and 2 deletions

View File

@@ -665,6 +665,44 @@ How to log a user out
immediately after logging out, do that *after* calling
:func:`django.contrib.auth.logout()`.
.. _topics-auth-signals:
Login and logout signals
------------------------
The auth framework uses two :ref:`signals <topic-signals>` that can be used for
notification when a user logs in or out.
**:data:`django.contrib.auth.signals.user_logged_in`**
Sent when a user logs in successfully.
Arguments sent with this signal:
``sender``
As above: the class of the user that just logged in.
``request``
The current :class:`~django.http.HttpRequest` instance.
``user``
The user instance that just logged in.
**:data:`django.contrib.auth.signals.user_logged_out`**
Sent when the logout method is called.
``sender``
As above: the class of the user that just logged out or ``None``
if the user was not authenticated.
``request``
The current :class:`~django.http.HttpRequest` instance.
``user``
The user instance that just logged out or ``None`` if the
user was not authenticated.
Limiting access to logged-in users
----------------------------------