Refresh
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Formulieren voor authenticatie."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class EmailAuthenticationForm(AuthenticationForm):
|
||||
"""Loginformulier dat het ``username``-veld presenteert als e-mailadres.
|
||||
|
||||
Het veld blijft ``username`` heten zodat ``LoginView`` en de authenticatie-backend
|
||||
onveranderd werken; alleen label, invoertype en foutmelding zijn aangepast.
|
||||
"""
|
||||
|
||||
error_messages = {
|
||||
**AuthenticationForm.error_messages,
|
||||
"invalid_login": _("E-mailadres of wachtwoord klopt niet."),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
field = self.fields["username"]
|
||||
field.label = _("E-mailadres")
|
||||
field.widget.attrs.update(
|
||||
{
|
||||
"type": "email",
|
||||
"autocomplete": "username",
|
||||
"autocapitalize": "none",
|
||||
"spellcheck": "false",
|
||||
"placeholder": "naam@organisatie.nl",
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user