From 5c6454e7fe48de0b1c2ec83c977f5bd2fc5eb165 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Fri, 16 Oct 2026 14:08:47 +0530 Subject: [PATCH 1/3] OpenConceptLab/ocl_online#517 | exact group-name matching hasAuthGroup matched by substring, so `pro` would match `mapper-approved`. It now matches the group name exactly. canSwitchServer checks the three server groups by name, which keeps its current behaviour. Co-Authored-By: Claude Haiku 5.5 --- src/common/authGroups.js | 2 ++ src/common/utils.js | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/common/authGroups.js diff --git a/src/common/authGroups.js b/src/common/authGroups.js new file mode 100644 index 000000000..55bbd0624 --- /dev/null +++ b/src/common/authGroups.js @@ -0,0 +1,2 @@ +// Exact group-name checks, kept free of UI imports so they can be unit tested. +export const hasAuthGroup = (user, groupName) => Boolean(user?.auth_groups?.includes(groupName)); diff --git a/src/common/utils.js b/src/common/utils.js index 8cfaf1ff5..3e9f6fe5f 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -16,6 +16,7 @@ import { import APIService from '../services/APIService'; import GAService from '../services/GAService'; import { ensureIdToken } from './ssoSession'; +import { hasAuthGroup } from './authGroups'; import { SERVER_CONFIGS } from './serverConfigs'; import { legacyHashRoute, isSameSitePath } from './history'; @@ -471,17 +472,20 @@ export const getFHIRServerConfigFromCurrentContext = () => { return getLocalFHIRServerConfig() || getDefaultFHIRServerConfig(); } +// Groups that can switch servers: the OCL and FHIR server groups. +const SERVER_SWITCH_GROUPS = [OCL_SERVERS_GROUP, OCL_FHIR_SERVERS_GROUP, HAPI_FHIR_SERVERS_GROUP]; + export const canSwitchServer = () => { const user = getCurrentUser(); return Boolean( getSelectedServerConfig() || get(user, 'is_superuser') || - hasAuthGroup(user, 'server') + SERVER_SWITCH_GROUPS.some(group => hasAuthGroup(user, group)) ); } -export const hasAuthGroup = (user, groupName) => Boolean(find(user?.auth_groups, group => group.includes(groupName))) +export { hasAuthGroup } from './authGroups'; export const canViewOperationsPanel = () => { const user = getCurrentUser() From 13c5fed7c2ed2c916e7a7e9b750bb59140c122cf Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Fri, 16 Oct 2026 14:10:37 +0530 Subject: [PATCH 2/3] OpenConceptLab/ocl_online#517 | drop unused canSwitchServer oclweb3 doesn't use the server groups; server switching is a legacy oclweb2 feature. Co-Authored-By: Claude Haiku 5.5 --- src/common/utils.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/common/utils.js b/src/common/utils.js index 3e9f6fe5f..85d1941d6 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -472,19 +472,6 @@ export const getFHIRServerConfigFromCurrentContext = () => { return getLocalFHIRServerConfig() || getDefaultFHIRServerConfig(); } -// Groups that can switch servers: the OCL and FHIR server groups. -const SERVER_SWITCH_GROUPS = [OCL_SERVERS_GROUP, OCL_FHIR_SERVERS_GROUP, HAPI_FHIR_SERVERS_GROUP]; - -export const canSwitchServer = () => { - const user = getCurrentUser(); - - return Boolean( - getSelectedServerConfig() || - get(user, 'is_superuser') || - SERVER_SWITCH_GROUPS.some(group => hasAuthGroup(user, group)) - ); -} - export { hasAuthGroup } from './authGroups'; export const canViewOperationsPanel = () => { From aee8e3212fde5b5df41b939eb31e7218c6d128c6 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Fri, 16 Oct 2026 14:12:20 +0530 Subject: [PATCH 3/3] OpenConceptLab/ocl_online#517 | keep exact hasAuthGroup in utils Co-Authored-By: Claude Haiku 5.5 --- src/common/authGroups.js | 2 -- src/common/utils.js | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 src/common/authGroups.js diff --git a/src/common/authGroups.js b/src/common/authGroups.js deleted file mode 100644 index 55bbd0624..000000000 --- a/src/common/authGroups.js +++ /dev/null @@ -1,2 +0,0 @@ -// Exact group-name checks, kept free of UI imports so they can be unit tested. -export const hasAuthGroup = (user, groupName) => Boolean(user?.auth_groups?.includes(groupName)); diff --git a/src/common/utils.js b/src/common/utils.js index 85d1941d6..dad2bd194 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -16,7 +16,6 @@ import { import APIService from '../services/APIService'; import GAService from '../services/GAService'; import { ensureIdToken } from './ssoSession'; -import { hasAuthGroup } from './authGroups'; import { SERVER_CONFIGS } from './serverConfigs'; import { legacyHashRoute, isSameSitePath } from './history'; @@ -472,7 +471,7 @@ export const getFHIRServerConfigFromCurrentContext = () => { return getLocalFHIRServerConfig() || getDefaultFHIRServerConfig(); } -export { hasAuthGroup } from './authGroups'; +export const hasAuthGroup = (user, groupName) => Boolean(user?.auth_groups?.includes(groupName)) export const canViewOperationsPanel = () => { const user = getCurrentUser()