mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-05 23:50:37 +00:00
feat: add more ACTIVE_USERS_PROVIDER checks
This commit is contained in:
parent
8bfeb37f9a
commit
0a77ac2230
|
@ -146,14 +146,20 @@ def update_user(
|
|||
raise UserIsProtected
|
||||
|
||||
if displayname:
|
||||
if isinstance(ACTIVE_USERS_PROVIDER, JsonUserRepository):
|
||||
raise ApiUsingWrongUserRepository
|
||||
if len(displayname) >= 512: # we don't know the limitations of each service
|
||||
raise DisplaynameTooLong
|
||||
|
||||
ACTIVE_USERS_PROVIDER.update_user(
|
||||
username=username,
|
||||
displayname=displayname,
|
||||
)
|
||||
|
||||
if directmemberof is not None:
|
||||
if isinstance(ACTIVE_USERS_PROVIDER, JsonUserRepository):
|
||||
raise ApiUsingWrongUserRepository
|
||||
|
||||
user = ACTIVE_USERS_PROVIDER.get_user_by_username(username=username)
|
||||
|
||||
groups_to_add = [item for item in directmemberof if item not in user.directmemberof] # type: ignore
|
||||
|
|
|
@ -21,6 +21,7 @@ from selfprivacy_api.graphql.mutations.mutation_interface import (
|
|||
GenericMutationReturn,
|
||||
)
|
||||
from selfprivacy_api.actions.users import (
|
||||
ApiUsingWrongUserRepository,
|
||||
create_user as create_user_action,
|
||||
delete_user as delete_user_action,
|
||||
update_user as update_user_action,
|
||||
|
@ -189,6 +190,7 @@ class UsersMutations:
|
|||
DisplaynameTooLong,
|
||||
KanidmCliSubprocessError,
|
||||
FailedToGetValidKanidmToken,
|
||||
ApiUsingWrongUserRepository,
|
||||
) as error:
|
||||
return return_failed_mutation_return(
|
||||
message=error.get_error_message(),
|
||||
|
@ -288,6 +290,7 @@ class UsersMutations:
|
|||
KanidmQueryError,
|
||||
KanidmCliSubprocessError,
|
||||
FailedToGetValidKanidmToken,
|
||||
ApiUsingWrongUserRepository,
|
||||
) as error:
|
||||
return PasswordResetLinkReturn(
|
||||
success=False,
|
||||
|
|
Loading…
Reference in a new issue