Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
c412aaca
Kaydet (Commit)
c412aaca
authored
Agu 10, 2016
tarafından
an0o0nym
Kaydeden (comit)
Tim Graham
Agu 10, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26957 -- Corrected authenticate() docs regarding User.is_active.
üst
0d18b065
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
default.txt
docs/topics/auth/default.txt
+18
-19
No files found.
docs/topics/auth/default.txt
Dosyayı görüntüle @
c412aaca
...
...
@@ -117,25 +117,21 @@ Authenticating users
.. function:: authenticate(\**credentials)
To authenticate a given username and password, use
:func:`~django.contrib.auth.authenticate()`. It takes credentials in the
form of keyword arguments, for the default configuration this is
``username`` and ``password``, and it returns
a :class:`~django.contrib.auth.models.User` object if the password is valid
for the given username. If the password is invalid,
:func:`~django.contrib.auth.authenticate()` returns ``None``. Example::
Use :func:`~django.contrib.auth.authenticate()` to verify a set of
credentials. It takes credentials as keyword arguments, ``username`` and
``password`` for the default case, checks them against each
:ref:`authentication backend <authentication-backends>`, and returns a
:class:`~django.contrib.auth.models.User` object if the credentials are
valid for a backend. If the credentials aren't valid for any backend or if
a backend raises :class:`~django.core.exceptions.PermissionDenied`, it
returns ``None``. For example::
from django.contrib.auth import authenticate
user = authenticate(username='john', password='secret')
if user is not None:
# the password verified for the user
if user.is_active:
print("User is valid, active and authenticated")
# A backend authenticated the credentials
else:
print("The password is valid, but the account has been disabled!")
else:
# the authentication system was unable to verify the username and password
print("The username and password were incorrect.")
# No backend authenticated the credentials
.. note::
...
...
@@ -348,11 +344,8 @@ If you have an authenticated user you want to attach to the current session
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
# Redirect to a success page.
else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
...
...
@@ -513,7 +506,8 @@ The ``login_required`` decorator
.. note::
The ``login_required`` decorator does NOT check the ``is_active`` flag on a
user.
user, but the default :setting:`AUTHENTICATION_BACKENDS` reject inactive
users.
.. seealso::
...
...
@@ -553,7 +547,8 @@ inheritance list.
.. note::
Just as the ``login_required`` decorator, this mixin does NOT check the
``is_active`` flag on a user.
``is_active`` flag on a user, but the default
:setting:`AUTHENTICATION_BACKENDS` reject inactive users.
.. currentmodule:: django.contrib.auth.decorators
...
...
@@ -1611,6 +1606,10 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`:
def confirm_login_allowed(self, user):
pass
(In this case, you'll also need to use an authentication backend that
allows inactive users, such as as
:class:`~django.contrib.auth.backends.AllowAllUsersModelBackend`.)
Or to allow only some active users to log in::
class PickyAuthenticationForm(AuthenticationForm):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment