As I understand it; once user has been sent a reset email, and successfully reset their password, the PasswordResetCompleteView is displayed. But what is displayed if the reset fails. I have provided my own HTML for the other authentication URL but am not sure what to do about this one.
urlpatterns = [
path('', views.home, name="home"),
path('profiles/login/', auth_views.LoginView.as_view(template_name="profiles/login.html", next_page="home", redirect_authenticated_user=True), name='login'),
path('profiles/logout/', auth_views.LogoutView.as_view(template_name="profiles/logout.html"), name='logout'),
path('profiles/create_profile/', views.create_profile, name='create_profile'),
path('profiles/password_change/', auth_views.PasswordChangeView.as_view(template_name="profiles/password_change.html"), name='password_change'),
path('profiles/password_change/done/', auth_views.PasswordChangeDoneView.as_view(template_name="profiles/password_change_done.html"), name='password_change_done'),
path('profiles/password_reset/', auth_views.PasswordResetView.as_view(template_name="profiles/password_reset.html"), name='password_reset'),
path('profiles/password_reset/done/', auth_views.PasswordResetDoneView.as_view(template_name="profiles/password_reset_done.html"), name='password_reset_done'),
path('profiles/reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('profiles/reset/done/', auth_views.PasswordResetCompleteView.as_view(template_name="profiles/password_reset_complete.html"), name='password_reset_complete'),
What do you mean by “if the reset fails”?
If the person doesn’t supply the same password in both fields, or if the password doesn’t satisfy the password requirements, the form is redisplayed showing the error message. (Typical Django form processing.)
I can’t remember now how I caused it, but i received a message saying the password could not be changed; The form submitted Ok but returned an error page. No matter what i try now i cant recreate it.
I’ll have to come back to it if i see it again.
I remembered what i did. I was testing the registration/password links and entered
reset/<uidb64>/<token>/ manually into my browser, and got the page saying:
Password reset unsuccessful
The password reset link was invalid, possibly because it has already been used. Please request a new password reset.
Hopefully the user will not see this, but just in case, how would i go about styling it.
Actually, users will see it more than you think. It’s common for someone to request that link, and when they don’t get the email “right away” to reclick the link to send the email again - and then click on the link in the first email sent. (When I say “common”, we see duplicate requests for password reset emails within a 5-minute window more than 1% of the time. I don’t remember the exact percentage when we looked at that, but it was higher than any of us expected.)
Anyway, if you look at the original template, password_reset_confirm.html, in django.contrib.admin.templates.registration, you’ll see that message. If you override that template with your own you can change that message any way you like.