Skip to content
Snippets Groups Projects
Commit bc85575e authored by Luka's avatar Luka Committed by Maarten de Waard
Browse files

Add app roles to userInfo when logging in

parent 61e512c2
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ from flask_cors import cross_origin
from datetime import timedelta
from areas import api_v1
from areas.apps import AppRole
from areas.apps import AppRole, App
from config import *
from helpers import HydraOauth, BadRequest, KratosApi
......@@ -40,7 +40,18 @@ def hydra_callback():
identity=token, expires_delta=timedelta(days=365)
)
app_role = AppRole.query.filter_by(user_id=identity["id"]).first()
apps = App.query.all()
app_roles = []
for app in apps:
tmp_app_role = AppRole.query.filter_by(
user_id=identity["id"], app_id=app.id
).first()
app_roles.append(
{
"name": app.slug,
"role_id": tmp_app_role.role_id if tmp_app_role else None,
}
)
return jsonify(
{
......@@ -50,7 +61,7 @@ def hydra_callback():
"email": user_info["email"],
"name": user_info["name"],
"preferredUsername": user_info["preferred_username"],
"role_id": app_role.role_id if app_role else None,
"app_roles": app_roles,
},
}
)
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