Allow users to temporarily deactivate their accounts (#2324)
This commit is contained in:
parent
3ebd957d3d
commit
eae1866992
16 changed files with 333 additions and 39 deletions
|
@ -7,6 +7,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
import pyotp
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.settings import DOMAIN
|
||||
from .custom_form import CustomForm
|
||||
|
||||
|
||||
|
@ -20,6 +21,21 @@ class LoginForm(CustomForm):
|
|||
"password": forms.PasswordInput(),
|
||||
}
|
||||
|
||||
def infer_username(self):
|
||||
"""Users may enter their localname, username, or email"""
|
||||
localname = self.data.get("localname")
|
||||
if "@" in localname: # looks like an email address to me
|
||||
try:
|
||||
return models.User.objects.get(email=localname).username
|
||||
except models.User.DoesNotExist: # maybe it's a full username?
|
||||
return localname
|
||||
return f"{localname}@{DOMAIN}"
|
||||
|
||||
def add_invalid_password_error(self):
|
||||
"""We don't want to be too specific about this"""
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.non_field_errors = _("Username or password are incorrect")
|
||||
|
||||
|
||||
class RegisterForm(CustomForm):
|
||||
class Meta:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue