From 19802f56ebbfcf6083a36989398e62c19c24431a Mon Sep 17 00:00:00 2001 From: Davor Date: Fri, 20 May 2022 13:52:22 +0200 Subject: [PATCH] fix logic for roles --- areas/roles/role_service.py | 5 ----- web/login/login.py | 8 +++++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/areas/roles/role_service.py b/areas/roles/role_service.py index 4b44793..7d70f99 100644 --- a/areas/roles/role_service.py +++ b/areas/roles/role_service.py @@ -9,9 +9,4 @@ class RoleService: @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() diff --git a/web/login/login.py b/web/login/login.py index 258df32..e33b974 100644 --- a/web/login/login.py +++ b/web/login/login.py @@ -262,9 +262,11 @@ def consent(): .filter(AppRole.user_id == user.uuid) ) for role_obj in role_objects: - role_name = RoleService.get_role_by_id(role_obj.role_id).name - if (role_name is not None): - roles.append(role_name) + app_role = RoleService.get_role_by_id(role_obj.role_id) + if (app_role is None): + roles.append('user') + continue + roles.append(app_role.name) current_app.logger.info(f"Using '{roles}' when applying consent for {kratos_id}")