fix issue with WordPress login
- resolving role name
This commit is contained in:
parent
5206c78998
commit
97d4f0845d
2 changed files with 13 additions and 1 deletions
|
@ -6,3 +6,12 @@ class RoleService:
|
||||||
def get_roles():
|
def get_roles():
|
||||||
roles = Role.query.all()
|
roles = Role.query.all()
|
||||||
return [{"id": r.id, "name": r.name} for r in roles]
|
return [{"id": r.id, "name": r.name} for r in roles]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_role_by_id(role_id):
|
||||||
|
if role_id is None:
|
||||||
|
role = Role()
|
||||||
|
role.name = 'user'
|
||||||
|
return role
|
||||||
|
|
||||||
|
return Role.query.filter_by(id=role_id).first()
|
||||||
|
|
|
@ -18,6 +18,7 @@ from helpers import KratosUser
|
||||||
from config import *
|
from config import *
|
||||||
from web import web
|
from web import web
|
||||||
from areas.apps import AppRole, App
|
from areas.apps import AppRole, App
|
||||||
|
from areas.roles import RoleService
|
||||||
|
|
||||||
|
|
||||||
# This is a circular import and should be solved differently
|
# This is a circular import and should be solved differently
|
||||||
|
@ -261,7 +262,9 @@ def consent():
|
||||||
.filter(AppRole.user_id == user.uuid)
|
.filter(AppRole.user_id == user.uuid)
|
||||||
)
|
)
|
||||||
for role_obj in role_objects:
|
for role_obj in role_objects:
|
||||||
roles.append(role_obj.role.name)
|
role_name = RoleService.get_role_by_id(role_obj.role_id).name
|
||||||
|
if (role_name is not None):
|
||||||
|
roles.append(role_name)
|
||||||
|
|
||||||
current_app.logger.info(f"Using '{roles}' when applying consent for {kratos_id}")
|
current_app.logger.info(f"Using '{roles}' when applying consent for {kratos_id}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue