From 978334706a2fdc82e854a33239bed4c5b9cfa167 Mon Sep 17 00:00:00 2001 From: Aaron Dalton Date: Tue, 6 Feb 2024 21:04:05 -0500 Subject: [PATCH] Un-nest tirtiary --- src/utils/auth/auth-helpers.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/utils/auth/auth-helpers.js b/src/utils/auth/auth-helpers.js index 3f0b94f5..b1ea1aab 100644 --- a/src/utils/auth/auth-helpers.js +++ b/src/utils/auth/auth-helpers.js @@ -34,21 +34,26 @@ function filterAllowedItems(perms, authGroups, groups, groupKey) { } export function readAuthSettings({ provider, groups } = {}) { + var group_array = []; + if (groups) { + if (Array.isArray(groups)) { + group_array = groups.map((group) => ({ + name: Object.keys(group)[0], + allowUsers: group.allowUsers, + allowGroups: group.allowGroups, + })); + } else { + group_array = Object.keys(groups).map((group) => ({ + name: group, + allowUsers: groups[group].allowUsers, + allowGroups: groups[group].allowGroups, + })); + } + } + return { provider: provider ? getProviderByKey(provider.type).create(provider) : NullAuthProvider.create(), - groups: groups - ? Array.isArray(groups) - ? groups.map((group) => ({ - name: Object.keys(group)[0], - allowUsers: group.allowUsers, - allowGroups: group.allowGroups, - })) - : Object.keys(groups).map((group) => ({ - name: group, - allowUsers: groups[group].allowUsers, - allowGroups: groups[group].allowGroups, - })) - : [], + groups: group_array, }; }