summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2006-05-16 21:18:37 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2006-05-16 21:18:37 +0000
commitd659956cf5e9dbe1b22e7eae7f7e75d186caa226 (patch)
treeab9b2ad255ce18b47ab45d5cae3a8e9690b4c850 /docs
parent63df9c1da6b090ab03a9bb892807914da9e71a17 (diff)
multi-auth: Fixed broken ReST formatting.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/authentication.txt58
1 files changed, 28 insertions, 30 deletions
diff --git a/docs/authentication.txt b/docs/authentication.txt
index 8cedeefedf..8e416c3e9e 100644
--- a/docs/authentication.txt
+++ b/docs/authentication.txt
@@ -668,37 +668,35 @@ authenticates against a username and password variable defined in your
``settings.py`` file and creates a Django user object the first time they
authenticate::
-from django.conf import settings
-from django.contrib.auth.models import User, check_password
+ from django.conf import settings
+ from django.contrib.auth.models import User, check_password
-class SettingsBackend:
- """
- Authenticate against vars in settings.py Use the login name, and a hash
- of the password. For example:
-
- ADMIN_LOGIN = 'admin'
- ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de'
- """
- def authenticate(self, username=None, password=None):
- login_valid = (settings.ADMIN_LOGIN == username)
- pwd_valid = check_password(password, settings.ADMIN_PASSWORD)
- if login_valid and pwd_valid:
- try:
- user = User.objects.get(username=username)
- except User.DoesNotExist:
- # Create a new user. Note that we can set password to anything
- # as it won't be checked, the password from settings.py will.
- user = User(username=username, password='get from settings.py')
- user.is_staff = True
- user.is_superuser = True
- user.save()
- return user
- return None
+ class SettingsBackend:
+ """
+ Authenticate against vars in settings.py Use the login name, and a hash
+ of the password. For example:
- def get_user(self, user_id):
- try:
- return User.objects.get(pk=user_id)
- except User.DoesNotExist:
+ ADMIN_LOGIN = 'admin'
+ ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de'
+ """
+ def authenticate(self, username=None, password=None):
+ login_valid = (settings.ADMIN_LOGIN == username)
+ pwd_valid = check_password(password, settings.ADMIN_PASSWORD)
+ if login_valid and pwd_valid:
+ try:
+ user = User.objects.get(username=username)
+ except User.DoesNotExist:
+ # Create a new user. Note that we can set password to anything
+ # as it won't be checked, the password from settings.py will.
+ user = User(username=username, password='get from settings.py')
+ user.is_staff = True
+ user.is_superuser = True
+ user.save()
+ return user
return None
-.. _django.contrib.auth.backends.SettingsBackend: http://code.djangoproject.com/browser/django/branches/magic-removal/django/contrib/auth/backends.py
+ def get_user(self, user_id):
+ try:
+ return User.objects.get(pk=user_id)
+ except User.DoesNotExist:
+ return None