mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
After discussing with Malcolm, added set_unusable_password() and has_usable_password() methods to the User object, plus tests and updated documentation
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5771 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5b898f3f94
commit
fd2b99b5f1
3 changed files with 51 additions and 6 deletions
|
@ -114,6 +114,17 @@ custom methods:
|
|||
string is the correct password for the user. (This takes care of the
|
||||
password hashing in making the comparison.)
|
||||
|
||||
* ``set_unusable_password()`` -- Marks the user as having no password set.
|
||||
This isn't the same as having a blank string for a password.
|
||||
``check_password()`` for this user will never return ``True``. Doesn't
|
||||
save the ``User`` object.
|
||||
|
||||
You may need this if authentication for your application takes place
|
||||
against an existing external source such as an LDAP directory.
|
||||
|
||||
* ``has_usable_password()`` -- Returns ``False`` if
|
||||
``set_unusable_password()`` has been called for this user.
|
||||
|
||||
* ``get_group_permissions()`` -- Returns a list of permission strings that
|
||||
the user has, through his/her groups.
|
||||
|
||||
|
@ -152,9 +163,11 @@ Manager functions
|
|||
|
||||
The ``User`` model has a custom manager that has the following helper functions:
|
||||
|
||||
* ``create_user(username, email, password)`` -- Creates, saves and returns
|
||||
a ``User``. The ``username``, ``email`` and ``password`` are set as
|
||||
given, and the ``User`` gets ``is_active=True``.
|
||||
* ``create_user(username, email, password=None)`` -- Creates, saves and
|
||||
returns a ``User``. The ``username``, ``email`` and ``password`` are set
|
||||
as given, and the ``User`` gets ``is_active=True``.
|
||||
|
||||
If no password is provided, ``set_unusable_password()`` will be called.
|
||||
|
||||
See _`Creating users` for example usage.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue