add password auth

This commit is contained in:
David Rodenkirchen 2024-08-19 12:09:56 +02:00
parent 51f1a5a2d8
commit c20d437b55

View File

@ -37,6 +37,13 @@ class UserService:
raise NameNotAllowedError(disallowed_char)
return self._db_service.update_user(user)
def is_login_valid(self, user_name_or_mail: str, password_clear_text: str) -> bool:
user = self.get_user(user_name_or_mail)
if not user:
return False
return user.user_password == sha256(password_clear_text.encode(encoding="utf-8")).hexdigest()
def _check_for_disallowed_char(self, name: str) -> Optional[str]:
for c in name:
if c not in self.ALLOWED_USER_NAME_SYMBOLS: