1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Merged multi-auth branch to trunk. See the authentication docs for the ramifications of this change. Many, many thanks to Joseph Kocherhans for the hard work!

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3226 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2006-06-28 16:37:02 +00:00
parent 4ea7a11659
commit aab3a418ac
10 changed files with 229 additions and 46 deletions

View File

@@ -0,0 +1,21 @@
from django.contrib.auth.models import User, check_password
class ModelBackend:
"""
Authenticate against django.contrib.auth.models.User
"""
# TODO: Model, login attribute name and password attribute name should be
# configurable.
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None