From b338e52aaa97fd9648d0b21e7251d1be60d669b5 Mon Sep 17 00:00:00 2001 From: Slavcho Ivanov Date: Sat, 15 Apr 2023 17:57:17 +0300 Subject: [PATCH] Fix the isAdmin function - we can have resource_access OR realm_access. The restrictions were too tight and we were not considering an admin user as such in some cases. --- src/common/util/roles.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/roles.ts b/src/common/util/roles.ts index 0de876eb4..915937444 100644 --- a/src/common/util/roles.ts +++ b/src/common/util/roles.ts @@ -53,7 +53,7 @@ export const canViewSupporters = (sessionRoles: SessionRoles): boolean => { } export const isAdmin = (session: Session | JWT | null): boolean => { - if (session && session.user && session.user.resource_access && session.user.realm_access) { + if (session && session.user) { const sessionRoles: SessionRoles = { realmRoles: session.user?.realm_access.roles ?? [], resourceRoles: session.user?.resource_access?.account.roles ?? [],