Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

newforms-admin: Fixed #4450 -- Added URL override for user password c…

…hanges in admin interface. Thanks for the help on this, Jakub Wisniowski.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5998 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5303028b32fd5c8b8febc9907a70b637ce020e39 1 parent 68b7bbb
Russell Keith-Magee freakboy3742 authored
Showing with 18 additions and 2 deletions.
  1. +18 −2 django/contrib/admin/sites.py
20 django/contrib/admin/sites.py
View
@@ -9,10 +9,13 @@
import cPickle as pickle
import datetime
import md5
+import re
ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
LOGIN_FORM_KEY = 'this_is_the_login_form'
+USER_CHANGE_PASSWORD_URL_RE = re.compile('auth/user/(\d+)/password')
+
class AlreadyRegistered(Exception):
pass
@@ -111,6 +114,7 @@ def root(self, request, url):
if not self.has_permission(request):
return self.login(request)
+
if url == '':
return self.index(request)
elif url == 'password_change':
@@ -119,8 +123,13 @@ def root(self, request, url):
return self.password_change_done(request)
elif url == 'jsi18n':
return self.i18n_javascript(request)
- elif '/' in url:
- return self.model_page(request, *url.split('/', 2))
+ else:
+ match = USER_CHANGE_PASSWORD_URL_RE.match(url)
+ if match:
+ return self.user_change_password(request, match.group(1))
+
+ if '/' in url:
+ return self.model_page(request, *url.split('/', 2))
raise http.Http404('The requested admin page does not exist.')
@@ -153,6 +162,13 @@ def password_change_done(self, request):
from django.contrib.auth.views import password_change_done
return password_change_done(request)
+ def user_change_password(self, request, id):
+ """
+ Handles the "user change password" task
+ """
+ from django.contrib.admin.views.auth import user_change_password
+ return user_change_password(request, id)
+
def i18n_javascript(self, request):
"""
Displays the i18n JavaScript that the Django admin requires.
Please sign in to comment.
Something went wrong with that request. Please try again.