feat: add new errors processing

This commit is contained in:
dettlaff 2024-12-11 05:48:30 +04:00
parent fbb2a67979
commit cf3e6fe39e
2 changed files with 11 additions and 2 deletions

View file

@ -47,6 +47,7 @@ class PasswordResetLinkReturn(MutationReturnInterface):
def get_user_by_username(username: str) -> Optional[User]:
# TODO: why isn't there TRY
user = actions_get_user_by_username(username=username)
if user is None:
return None

View file

@ -39,10 +39,12 @@ from selfprivacy_api.repositories.users.exceptions import (
UserNotFound,
SelfPrivacyAppIsOutdate,
)
from selfprivacy_api import PLEASE_UPDATE_APP_TEXT
from selfprivacy_api.repositories.users.kanidm_user_repository import (
from selfprivacy_api.repositories.users.exceptions_kanidm import (
KanidmDidNotReturnAdminPassword,
KanidmReturnEmptyResponse,
KanidmReturnUnknownResponseType,
)
from selfprivacy_api import PLEASE_UPDATE_APP_TEXT
FAILED_TO_SETUP_PASSWORD_TEXT = "Failed to set a password for a user. The problem occurred due to an old version of the SelfPrivacy app."
@ -98,6 +100,8 @@ class UsersMutations:
UsernameTooLong,
InvalidConfiguration,
KanidmDidNotReturnAdminPassword,
KanidmReturnUnknownResponseType,
KanidmReturnEmptyResponse,
) as error:
return return_failed_mutation_return(
message=error.get_error_message(),
@ -171,6 +175,8 @@ class UsersMutations:
PasswordIsEmpty,
SelfPrivacyAppIsOutdate,
KanidmDidNotReturnAdminPassword,
KanidmReturnUnknownResponseType,
KanidmReturnEmptyResponse,
) as error:
return return_failed_mutation_return(
message=error.get_error_message(),
@ -260,6 +266,8 @@ class UsersMutations:
NoPasswordResetLinkFoundInResponse,
KanidmDidNotReturnAdminPassword,
RootIsNotAvailableForModification,
KanidmReturnUnknownResponseType,
KanidmReturnEmptyResponse,
) as error:
return PasswordResetLinkReturn(
success=False,