mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-07 00:20:37 +00:00
feat: plugin error check
This commit is contained in:
parent
17826e6437
commit
fb97714dd7
|
@ -157,13 +157,10 @@ class KanidmUserRepository(AbstractUserRepository):
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
|
|
||||||
if 'errors' in response_data and response_data['errors']:
|
if 'plugin' in response_data.get('data', {}):
|
||||||
error_message = response_data['errors'][0].get('message')
|
plugin_error = response_data['data']['plugin']
|
||||||
if error_message:
|
if plugin_error.get("attrunique") == "duplicate value detected":
|
||||||
if "duplicate value detected" in error_message:
|
raise UserAlreadyExists("Duplicate value detected when creating user.")
|
||||||
raise UserAlreadyExists
|
|
||||||
else:
|
|
||||||
raise KanidmQueryError(f"Kanidm returned an error: {error_message}")
|
|
||||||
|
|
||||||
return response_data
|
return response_data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue