Allow changing username

This commit is contained in:
CasVT
2025-04-24 16:15:38 +02:00
parent 4f77435801
commit cefc1a9593
3 changed files with 15 additions and 13 deletions

View File

@@ -81,19 +81,15 @@ class User:
should not be changed.
Raises:
OperationNotAllowed: The user is an admin and is trying to change
the username.
UsernameInvalid: The new username is not valid.
UsernameTaken: The new username is already taken.
"""
if not (new_username or new_password):
return
user_data = self.get()
if new_username is not None:
if user_data.admin:
raise OperationNotAllowed(
"Changing the username of an admin account"
)
is_valid_username(new_username)
if self.user_db.taken(new_username):