limit username length
This commit is contained in:
parent
e3359229ec
commit
2326907141
@ -41,7 +41,7 @@ class UserInfoAndLoginBox(Component):
|
||||
|
||||
@staticmethod
|
||||
def get_greeting() -> str:
|
||||
return choice(["Guten Tacho", "Tuten Gag", "Hallöchen mit Öchen", "Servus", "Moinjour", "Hallöchen Popöchen", "Heyho", "Moinsen"])
|
||||
return choice(["Guten Tacho", "Tuten Gag", "Servus", "Moinjour", "Hallöchen Popöchen", "Heyho", "Moinsen"])
|
||||
|
||||
# @FixMe: If the user logs out and then tries to log back in, it does not work
|
||||
# If the user navigates to another page and then tries again. It works.
|
||||
|
||||
@ -29,6 +29,11 @@ class RegisterPage(Component):
|
||||
except EmailNotValidError:
|
||||
self.email_input.is_valid = False
|
||||
|
||||
def on_user_name_input_change(self, _: TextInputChangeEvent) -> None:
|
||||
current_text = self.user_name_input.text
|
||||
if len(current_text) > UserService.MAX_USERNAME_LENGTH:
|
||||
self.user_name_input.text = current_text[:UserService.MAX_USERNAME_LENGTH]
|
||||
|
||||
async def on_submit_button_pressed(self) -> None:
|
||||
self.submit_button.is_loading = True
|
||||
await self.submit_button.force_refresh()
|
||||
@ -95,7 +100,8 @@ class RegisterPage(Component):
|
||||
margin_left=1,
|
||||
margin_right=1,
|
||||
margin_bottom=1,
|
||||
grow_x=True
|
||||
grow_x=True,
|
||||
on_change=self.on_user_name_input_change
|
||||
)
|
||||
self.email_input = TextInput(
|
||||
label="E-Mail Adresse",
|
||||
|
||||
@ -12,6 +12,7 @@ class NameNotAllowedError(Exception):
|
||||
|
||||
class UserService:
|
||||
ALLOWED_USER_NAME_SYMBOLS = ascii_letters + digits + "!#$%&*+,-./:;<=>?[]^_{|}~"
|
||||
MAX_USERNAME_LENGTH = 14
|
||||
|
||||
def __init__(self, db_service: DatabaseService) -> None:
|
||||
self._db_service = db_service
|
||||
|
||||
Loading…
Reference in New Issue
Block a user