fix: 🙋 allow case-insensitive login
This commit is contained in:
parent
ab34546528
commit
e1a2618d46
2 changed files with 14 additions and 0 deletions
12
moku/forms/auth.py
Normal file
12
moku/forms/auth.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from django.contrib.auth.forms import AuthenticationForm as BaseAuthenticationForm
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AuthenticationForm(BaseAuthenticationForm):
|
||||
error_messages = {
|
||||
"invalid_login": _("sorry! that username and password didn't work."),
|
||||
"inactive": _("your account has been deactivated."),
|
||||
}
|
||||
|
||||
def clean_username(self):
|
||||
return self.cleaned_data.get("username").lower()
|
||||
|
|
@ -5,6 +5,7 @@ from django.shortcuts import redirect
|
|||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from moku.forms.auth import AuthenticationForm
|
||||
from moku.views.base import View
|
||||
|
||||
|
||||
|
|
@ -12,6 +13,7 @@ class LoginView(View, BaseLoginView):
|
|||
"""Allows users to log in by username and password."""
|
||||
|
||||
template_name = "moku/login.jinja"
|
||||
form_class = AuthenticationForm
|
||||
page_title = "log in"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue