Skip to content

Commit d659956

Browse files
committed
multi-auth: Fixed broken ReST formatting.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 63df9c1 commit d659956

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

docs/authentication.txt

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -668,37 +668,35 @@ authenticates against a username and password variable defined in your
668668
``settings.py`` file and creates a Django user object the first time they
669669
authenticate::
670670

671-
from django.conf import settings
672-
from django.contrib.auth.models import User, check_password
673-
674-
class SettingsBackend:
675-
"""
676-
Authenticate against vars in settings.py Use the login name, and a hash
677-
of the password. For example:
678-
679-
ADMIN_LOGIN = 'admin'
680-
ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de'
681-
"""
682-
def authenticate(self, username=None, password=None):
683-
login_valid = (settings.ADMIN_LOGIN == username)
684-
pwd_valid = check_password(password, settings.ADMIN_PASSWORD)
685-
if login_valid and pwd_valid:
686-
try:
687-
user = User.objects.get(username=username)
688-
except User.DoesNotExist:
689-
# Create a new user. Note that we can set password to anything
690-
# as it won't be checked, the password from settings.py will.
691-
user = User(username=username, password='get from settings.py')
692-
user.is_staff = True
693-
user.is_superuser = True
694-
user.save()
695-
return user
696-
return None
697-
698-
def get_user(self, user_id):
699-
try:
700-
return User.objects.get(pk=user_id)
701-
except User.DoesNotExist:
671+
from django.conf import settings
672+
from django.contrib.auth.models import User, check_password
673+
674+
class SettingsBackend:
675+
"""
676+
Authenticate against vars in settings.py Use the login name, and a hash
677+
of the password. For example:
678+
679+
ADMIN_LOGIN = 'admin'
680+
ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de'
681+
"""
682+
def authenticate(self, username=None, password=None):
683+
login_valid = (settings.ADMIN_LOGIN == username)
684+
pwd_valid = check_password(password, settings.ADMIN_PASSWORD)
685+
if login_valid and pwd_valid:
686+
try:
687+
user = User.objects.get(username=username)
688+
except User.DoesNotExist:
689+
# Create a new user. Note that we can set password to anything
690+
# as it won't be checked, the password from settings.py will.
691+
user = User(username=username, password='get from settings.py')
692+
user.is_staff = True
693+
user.is_superuser = True
694+
user.save()
695+
return user
702696
return None
703697

704-
.. _django.contrib.auth.backends.SettingsBackend: http://code.djangoproject.com/browser/django/branches/magic-removal/django/contrib/auth/backends.py
698+
def get_user(self, user_id):
699+
try:
700+
return User.objects.get(pk=user_id)
701+
except User.DoesNotExist:
702+
return None

0 commit comments

Comments
 (0)