diff --git a/user_mgmt/handler.py b/user_mgmt/handler.py index bbdd436..88c75a4 100644 --- a/user_mgmt/handler.py +++ b/user_mgmt/handler.py @@ -75,7 +75,7 @@ async def is_associate(self, experiment, username): def is_super_admin(self): """Is the current user a super admin?""" - return '/admin' in self.auth_data['groups'] + return '/admin' in self.auth_data.get('groups', []) async def get_admins(self, group_path): ret = await self.group_cache.get_members(group_path+'/_admin') @@ -110,7 +110,7 @@ async def get_admin_groups(self): if self.is_super_admin(): # super admin - all groups admin_groups = await self.group_cache.list_groups() else: - admin_groups = [g[:-7] for g in self.auth_data['groups'] if g.endswith('/_admin')] + admin_groups = [g[:-7] for g in self.auth_data.get('groups', []) if g.endswith('/_admin')] groups = set() for group in admin_groups: val = group.strip('/').split('/') @@ -130,7 +130,7 @@ async def get_admin_institutions(self): val = group.split('/') insts[val[2]].append(val[3]) else: - admin_groups = [g[:-7] for g in self.auth_data['groups'] if g.endswith('/_admin')] + admin_groups = [g[:-7] for g in self.auth_data.get('groups', []) if g.endswith('/_admin')] insts = defaultdict(list) for group in admin_groups: val = group.strip('/').split('/')