I made a custom password_reset_confirm.html
template. But when a user enters a new password and hits submit, the browser does not redirect to the admin view password_reset_complete
.
Here's the form I made in the custom password_reset_confirm.html
template:
<div ng-app="app" ng-controller="Ctrl"> <form id="reset-pw-confirm-form" name="newPWForm" method="post" action=""> {% csrf_token %} <input id="id_new_password1" type="[[[ newPW.showPW ? 'text' : 'password' ]]]" name="new_password1" ng-model="newPW.pw" ng-minlength="8" ng-maxlength="32" required> <button class="btn btn-primary" type="submit" ng-disabled="!newPW.pw">Submit</button> <input id="id_new_password2" type="hidden" value="[[[ newPW ]]]" name="new_password2" ng-model="newPW" ng-minlength="8" ng-maxlength="32" required> </form> </div>
When I fill out the password and hit submit, the browser sends a POST request to the same URL it landed on, but the page seems to just refresh with nothing changed. The user's password remains unchanged. It seems Django's auth/views.py
did not execute properly.
In that view, there's this code:
if post_reset_redirect is None: post_reset_redirect = reverse('password_reset_complete') else: post_reset_redirect = resolve_url(post_reset_redirect)
When I have the view print post_reset_redirect
, it prints None
. Could this be the issue?
How can I make my custom template compatible with Django's password_reset_confirm
view?
2 Answers
Answers 1
When you specifies "action" attribute for the form it will be used as your link for data sending so probably your logic isn't handled. Try to remove it and check you js files that the data is sent to the the specified link. Also please check all required parameters for the password_reset_confirm https://docs.djangoproject.com/en/1.8/_modules/django/contrib/auth/views/
Answers 2
My hidden input
's value
and ng-model
attributes needed to be set to newPW.pw
.
0 comments:
Post a Comment