From 66476ed2540431cb25c88d835ca94720807e687e Mon Sep 17 00:00:00 2001 From: pycook Date: Tue, 7 Apr 2020 18:02:26 +0800 Subject: [PATCH] Fix the judgment of app admin --- cmdb-api/api/lib/perm/acl/acl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmdb-api/api/lib/perm/acl/acl.py b/cmdb-api/api/lib/perm/acl/acl.py index e40a9bd..d1edd12 100644 --- a/cmdb-api/api/lib/perm/acl/acl.py +++ b/cmdb-api/api/lib/perm/acl/acl.py @@ -127,8 +127,9 @@ def is_app_admin(app=None): app = app or 'cmdb' app_id = AppCache.get(app).id - for role in session.get("acl", {}).get("parentRoles", []): - if RoleCache.get_by_name(app_id, role).is_app_admin: + for role_name in session.get("acl", {}).get("parentRoles", []): + role = RoleCache.get_by_name(app_id, role_name) + if role and role.is_app_admin: return True return False