Skip to content

Commit

Permalink
fix(mfa): Use "one-time-code" autocomplete hint
Browse files Browse the repository at this point in the history
* fix(mfa): Use "one-time-code" autocomplete hint

This small change also makes it a little easier to detect the field in custom form templates (e.g. with `django-widget-tweaks`).

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#sect16

* fix(mfa): Add autocomplete attribute to TOTP setup form
  • Loading branch information
julianwachholz authored Dec 1, 2023
1 parent e39aed5 commit 0e25434
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions allauth/mfa/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AuthenticateForm(forms.Form):
code = forms.CharField(
label=_("Code"),
widget=forms.TextInput(
attrs={"placeholder": _("Code"), "autocomplete": "off"},
attrs={"placeholder": _("Code"), "autocomplete": "one-time-code"},
),
)

Expand Down Expand Up @@ -49,7 +49,12 @@ def save(self):


class ActivateTOTPForm(forms.Form):
code = forms.CharField(label=_("Authenticator code"))
code = forms.CharField(
label=_("Authenticator code"),
widget=forms.TextInput(
attrs={"placeholder": _("Code"), "autocomplete": "one-time-code"},
),
)

def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user")
Expand Down

0 comments on commit 0e25434

Please sign in to comment.