mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
multi-auth: Updated admin system to use new auth api.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2888 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c9136c0bff
commit
89c6a07a5f
@ -1,6 +1,7 @@
|
||||
from django import http, template
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User, SESSION_KEY
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth import authenticate, login
|
||||
from django.shortcuts import render_to_response
|
||||
from django.utils.translation import gettext_lazy
|
||||
import base64, datetime, md5
|
||||
@ -69,10 +70,10 @@ def staff_member_required(view_func):
|
||||
return _display_login_form(request, message)
|
||||
|
||||
# Check the password.
|
||||
username = request.POST.get('username', '')
|
||||
try:
|
||||
user = User.objects.get(username=username, is_staff=True)
|
||||
except User.DoesNotExist:
|
||||
username = request.POST.get('username', None)
|
||||
password = request.POST.get('password', None)
|
||||
user = authenticate(username=username, password=password)
|
||||
if user is None:
|
||||
message = ERROR_MESSAGE
|
||||
if '@' in username:
|
||||
# Mistakenly entered e-mail address instead of username? Look it up.
|
||||
@ -86,8 +87,9 @@ def staff_member_required(view_func):
|
||||
|
||||
# The user data is correct; log in the user in and continue.
|
||||
else:
|
||||
if user.check_password(request.POST.get('password', '')):
|
||||
request.session[SESSION_KEY] = user.id
|
||||
if user.is_staff:
|
||||
login(request, user)
|
||||
# TODO: set last_login with an event.
|
||||
user.last_login = datetime.datetime.now()
|
||||
user.save()
|
||||
if request.POST.has_key('post_data'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user