Skip to content

Commit

Permalink
Make sure password strength hint is visible
Browse files Browse the repository at this point in the history
  • Loading branch information
rixx committed Oct 9, 2024
1 parent 65c4edb commit 63b1ea5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/pretalx/cfp/forms/auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.core.exceptions import ValidationError

from pretalx.common.forms.fields import PasswordConfirmationField, PasswordField
from pretalx.common.forms.fields import NewPasswordConfirmationField, NewPasswordField
from pretalx.common.text.phrases import phrases
from pretalx.person.models import User

Expand All @@ -25,8 +25,8 @@ def clean(self):


class RecoverForm(forms.Form):
password = PasswordField(label=phrases.base.new_password, required=False)
password_repeat = PasswordConfirmationField(
password = NewPasswordField(label=phrases.base.new_password, required=False)
password_repeat = NewPasswordConfirmationField(
label=phrases.base.password_repeat,
required=False,
confirm_with="password",
Expand Down
4 changes: 2 additions & 2 deletions src/pretalx/common/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __call__(self, value):
return validate_password(value)


class PasswordField(CharField):
class NewPasswordField(CharField):
default_validators = [GlobalValidator()]

def __init__(self, *args, **kwargs):
Expand All @@ -35,7 +35,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class PasswordConfirmationField(CharField):
class NewPasswordConfirmationField(CharField):
def __init__(self, *args, **kwargs):
kwargs["widget"] = kwargs.get(
"widget",
Expand Down
1 change: 1 addition & 0 deletions src/pretalx/common/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def render(self, name, value, attrs=None, renderer=None):
)

self.attrs = add_class(self.attrs, "password_strength")
self.attrs["autocomplete"] = "new-password"
return mark_safe(super().render(name, value, self.attrs) + markup)


Expand Down
3 changes: 1 addition & 2 deletions src/pretalx/common/templates/common/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

{% compress js %}
<script defer src="{% static "vendored/zxcvbn.js" %}"></script>
<script defer src="{% static "common/js/base.js" %}"></script>
<script defer src="{% static "common/js/password_strength.js" %}"></script>
<script defer src="{% static "common/js/formTools.js" %}"></script>
<script defer src="{% static "common/js/password_strength.js" %}"></script>
{% endcompress %}

{% if not hide_login %}
Expand Down
13 changes: 6 additions & 7 deletions src/pretalx/person/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from pretalx.cfp.forms.cfp import CfPFormMixin
from pretalx.common.forms.fields import (
ImageField,
PasswordConfirmationField,
PasswordField,
NewPasswordConfirmationField,
NewPasswordField,
SizeFileField,
)
from pretalx.common.forms.mixins import (
Expand Down Expand Up @@ -53,12 +53,11 @@ class UserForm(CfPFormMixin, forms.Form):
required=False,
widget=forms.EmailInput(attrs={"autocomplete": "email"}),
)
register_password = PasswordField(
register_password = NewPasswordField(
label=_("Password"),
required=False,
widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}),
)
register_password_repeat = PasswordConfirmationField(
register_password_repeat = NewPasswordConfirmationField(
label=_("Password (again)"),
required=False,
confirm_with="register_password",
Expand Down Expand Up @@ -299,8 +298,8 @@ class LoginInfoForm(forms.ModelForm):
old_password = forms.CharField(
widget=forms.PasswordInput, label=_("Password (current)"), required=True
)
password = PasswordField(label=phrases.base.new_password, required=False)
password_repeat = PasswordConfirmationField(
password = NewPasswordField(label=phrases.base.new_password, required=False)
password_repeat = NewPasswordConfirmationField(
label=phrases.base.password_repeat, required=False, confirm_with="password"
)

Expand Down

0 comments on commit 63b1ea5

Please sign in to comment.