mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +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:
@@ -12,6 +12,9 @@ A list of all the signals that Django sends.
|
||||
The :doc:`comment framework </ref/contrib/comments/index>` sends a :doc:`set
|
||||
of comment-related signals </ref/contrib/comments/signals>`.
|
||||
|
||||
The :ref:`authentication framework <topics-auth>` sends :ref:`signals when
|
||||
a user is logged in / out <topics-auth-signals>`.
|
||||
|
||||
Model signals
|
||||
=============
|
||||
|
||||
|
||||
@@ -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
|
||||
----------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user