Skip to content

Commit

Permalink
feat(forms): add password_validation help text to password field on s…
Browse files Browse the repository at this point in the history
…et/change/signup forms

* feat(forms): add password_validation help text to password field on set/change/signup forms

* change(forms): corrected formatting via black

* bump changelog up to unreleased section
  • Loading branch information
iarp authored Sep 12, 2023
1 parent cb6ef5d commit 347591d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Guoyu Hao
Haesung Park
Hatem Nassrat
Hyunwoo Shim
Ian R-P
Ignacio Ocampo
Illia Volochii
J. Erm
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Note worthy changes
-------------------

- Added django password validation help text to password1 on set/change/signup forms.
- ...


Expand Down
15 changes: 12 additions & 3 deletions allauth/account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from importlib import import_module

from django import forms
from django.contrib.auth import password_validation
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.sites.shortcuts import get_current_site
from django.core import exceptions, validators
Expand Down Expand Up @@ -394,7 +395,9 @@ class SignupForm(BaseSignupForm):
def __init__(self, *args, **kwargs):
super(SignupForm, self).__init__(*args, **kwargs)
self.fields["password1"] = PasswordField(
label=_("Password"), autocomplete="new-password"
label=_("Password"),
autocomplete="new-password",
help_text=password_validation.password_validators_help_text_html(),
)
if app_settings.SIGNUP_PASSWORD_ENTER_TWICE:
self.fields["password2"] = PasswordField(
Expand Down Expand Up @@ -502,7 +505,10 @@ class ChangePasswordForm(PasswordVerificationMixin, UserForm):
oldpassword = PasswordField(
label=_("Current Password"), autocomplete="current-password"
)
password1 = SetPasswordField(label=_("New Password"))
password1 = SetPasswordField(
label=_("New Password"),
help_text=password_validation.password_validators_help_text_html(),
)
password2 = PasswordField(label=_("New Password (again)"))

def __init__(self, *args, **kwargs):
Expand All @@ -519,7 +525,10 @@ def save(self):


class SetPasswordForm(PasswordVerificationMixin, UserForm):
password1 = SetPasswordField(label=_("Password"))
password1 = SetPasswordField(
label=_("Password"),
help_text=password_validation.password_validators_help_text_html(),
)
password2 = PasswordField(label=_("Password (again)"))

def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 347591d

Please sign in to comment.