diff --git a/django/contrib/auth/utils.py b/django/contrib/auth/utils.py
new file mode 100644
index 0000000..93e044a
-
|
+
|
|
| 1 | from django.contrib.auth.models import User |
| 2 | from django.contrib.auth.tokens import default_token_generator |
| 3 | from django.utils.http import base36_to_int |
| 4 | |
| 5 | def confirm_password_reset(uidb36, token, token_generator=default_token_generator): |
| 6 | try: |
| 7 | uid_int = base36_to_int(uidb36) |
| 8 | user = User.objects.get(id=uid_int) |
| 9 | except (ValueError, User.DoesNotExist): |
| 10 | user = None |
| 11 | |
| 12 | return user, token_generator.check_token(user, token) if user else False |
| 13 | |
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index c86ef53..e990abc 100644
a
|
b
|
from django.conf import settings
|
4 | 4 | from django.core.urlresolvers import reverse |
5 | 5 | from django.http import HttpResponseRedirect, QueryDict |
6 | 6 | from django.template.response import TemplateResponse |
7 | | from django.utils.http import base36_to_int |
8 | 7 | from django.utils.translation import ugettext as _ |
9 | 8 | from django.views.decorators.debug import sensitive_post_parameters |
10 | 9 | from django.views.decorators.cache import never_cache |
… |
… |
from django.views.decorators.csrf import csrf_protect
|
14 | 13 | from django.contrib.auth import REDIRECT_FIELD_NAME, login as auth_login, logout as auth_logout |
15 | 14 | from django.contrib.auth.decorators import login_required |
16 | 15 | from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm |
17 | | from django.contrib.auth.models import User |
18 | 16 | from django.contrib.auth.tokens import default_token_generator |
| 17 | from django.contrib.auth.utils import confirm_password_reset |
19 | 18 | from django.contrib.sites.models import get_current_site |
20 | 19 | |
21 | 20 | |
… |
… |
def password_reset_confirm(request, uidb36=None, token=None,
|
194 | 193 | assert uidb36 is not None and token is not None # checked by URLconf |
195 | 194 | if post_reset_redirect is None: |
196 | 195 | post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete') |
197 | | try: |
198 | | uid_int = base36_to_int(uidb36) |
199 | | user = User.objects.get(id=uid_int) |
200 | | except (ValueError, User.DoesNotExist): |
201 | | user = None |
| 196 | user, validlink = confirm_password_reset(uidb36, token, token_generator=token_generator) |
202 | 197 | |
203 | | if user is not None and token_generator.check_token(user, token): |
204 | | validlink = True |
| 198 | if user is not None and validlink: |
205 | 199 | if request.method == 'POST': |
206 | 200 | form = set_password_form(user, request.POST) |
207 | 201 | if form.is_valid(): |
… |
… |
def password_reset_confirm(request, uidb36=None, token=None,
|
210 | 204 | else: |
211 | 205 | form = set_password_form(None) |
212 | 206 | else: |
213 | | validlink = False |
214 | 207 | form = None |
215 | 208 | context = { |
216 | 209 | 'form': form, |