MR comments
- NO_ACCESS_ROLE_ID constant moved to models.py - added docstring for batch create request body
This commit is contained in:
parent
d140a1a6cb
commit
66b44ae1a0
3 changed files with 7 additions and 7 deletions
|
@ -3,6 +3,8 @@ from database import db
|
|||
|
||||
|
||||
class Role(db.Model):
|
||||
NO_ACCESS_ROLE_ID = 3
|
||||
|
||||
id = db.Column(Integer, primary_key=True)
|
||||
name = db.Column(String(length=64))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from database import db
|
||||
from areas.apps import App, AppRole, AppsService
|
||||
from areas.roles.role_service import RoleService
|
||||
from areas.roles import Role, RoleService
|
||||
from helpers import KratosApi
|
||||
|
||||
from flask import current_app
|
||||
|
@ -9,8 +9,6 @@ from helpers.error_handler import KratosError
|
|||
|
||||
|
||||
class UserService:
|
||||
no_access_role_id = 3
|
||||
|
||||
@staticmethod
|
||||
def get_users():
|
||||
res = KratosApi.get("/admin/identities").json()
|
||||
|
@ -39,7 +37,7 @@ class UserService:
|
|||
app = App.query.filter_by(slug=ar["name"]).first()
|
||||
app_role = AppRole(
|
||||
user_id=res["id"],
|
||||
role_id=ar["role_id"] if "role_id" in ar else UserService.no_access_role_id,
|
||||
role_id=ar["role_id"] if "role_id" in ar else Role.NO_ACCESS_ROLE_ID,
|
||||
app_id=app.id,
|
||||
)
|
||||
|
||||
|
@ -50,7 +48,7 @@ class UserService:
|
|||
for app in all_apps:
|
||||
app_role = AppRole(
|
||||
user_id=res["id"],
|
||||
role_id=UserService.no_access_role_id,
|
||||
role_id=Role.NO_ACCESS_ROLE_ID,
|
||||
app_id=app.id,
|
||||
)
|
||||
|
||||
|
@ -100,8 +98,7 @@ class UserService:
|
|||
@staticmethod
|
||||
def post_multiple_users(data):
|
||||
# check if data is array
|
||||
# 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
|
||||
# for every item in array call Kratos
|
||||
created_users = []
|
||||
existing_users = []
|
||||
creation_failed_users = []
|
||||
|
|
|
@ -70,6 +70,7 @@ def delete_user(id):
|
|||
@expects_json(schema_multiple)
|
||||
@admin_required()
|
||||
def post_multiple_users():
|
||||
"""Expects an array of user JSON schema in request body."""
|
||||
data = request.get_json()
|
||||
res = UserService.post_multiple_users(data)
|
||||
return jsonify(res)
|
||||
|
|
Loading…
Reference in a new issue