Skip to content
Snippets Groups Projects
Commit cc7ff9d3 authored by Davor's avatar Davor
Browse files

modify user batch create

parent 8eacdc8d
No related branches found
No related tags found
No related merge requests found
......@@ -98,17 +98,21 @@ class UserService:
# for every item in array call Kratos - check if there can be batch create on Kratos
# - if yes, what happens with the batch if there is at least one existing email
created_users = []
not_created_users = []
for user_data in data:
for user_data in data['users']:
user_mail = user_data["email"]
if not user_mail:
return
try:
user = UserService.post_user(user)
user = UserService.post_user(user_data)
current_app.logger.info(f"Batch create user: {user_mail}")
created_users.append(user)
except Exception:
current_app.logger.error(
"Exception calling Kratos %s\n on creating user %s, %s\n",
Exception, user_data["email"], user_data["name"])
except Exception as error:
current_app.logger.error(f"Exception calling Kratos: {error} on creating user: {user_mail}")
not_created_users.append(user_mail)
return created_users
return {"created_users": created_users, "not_created_users": not_created_users}
@staticmethod
def __insertAppRoleToUser(userId, userRes):
......
......@@ -33,8 +33,10 @@ schema = {
}
schema_multiple = {
"type": "array",
"items": {
"$ref": schema
"users": {
"type": "array",
"items": {
"$ref": schema
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment