Skip to content

Commit 435d5fa

Browse files
committed
refactor: enhance getAllowedVOs to return all VOs for 'oscar' user and handle empty oidc_groups
1 parent ef61d13 commit 435d5fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib/utils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@ export function getUserVOs(authData: AuthData): string[] {
9696
}
9797

9898
export function getAllowedVOs(systemConfig: {config: SystemConfig} | null, authData: AuthData): string[] {
99-
if (!systemConfig || !systemConfig.config) return [];
99+
if (!systemConfig || !systemConfig.config || !systemConfig.config.oidc_groups || systemConfig.config.oidc_groups.length === 0) return [];
100+
// If user is oscar, return all allowed VOs from system config
101+
if (authData.user === "oscar") return systemConfig.config.oidc_groups;
102+
// Get user's VOs
100103
const userVOs = getUserVOs(authData);
101-
return systemConfig.config.oidc_groups.filter((vo) => authData.user === "oscar" || userVOs.includes(vo));
104+
// If user has no VOs, return all allowed VOs from system config
105+
if (userVOs.length === 0) return systemConfig.config.oidc_groups;
106+
// Filter allowed VOs based on user's VOs
107+
const filteredVOs = systemConfig.config.oidc_groups.filter((vo) => userVOs.includes(vo));
108+
return filteredVOs;
102109
}
110+
103111
function sleep(ms: number) {
104112
return new Promise(resolve => setTimeout(resolve, ms));
105113
}

0 commit comments

Comments
 (0)