fix: 🙋‍ allow case-insensitive login

This commit is contained in:
m5ka 2024-03-26 17:05:43 +00:00
parent ab34546528
commit e1a2618d46
2 changed files with 14 additions and 0 deletions

12
moku/forms/auth.py Normal file
View 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()

View file

@ -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):