From 24fdef92b417f3ccd118a34ee1a24eaefa50ad81 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 4 Aug 2022 11:28:55 +0100 Subject: [PATCH] Fix issue when using an invalid group ID in url --- .../portal/apps/_components/AcessFilter.svelte | 12 ++---------- .../builder/portal/manage/groups/[groupId].svelte | 5 +++++ .../pages/builder/portal/manage/groups/index.svelte | 4 +--- packages/builder/src/stores/portal/groups.js | 5 +---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte b/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte index d0662e7b41..a75ed7c4de 100644 --- a/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte +++ b/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte @@ -1,7 +1,7 @@ !group?.users.map(y => y._id).includes(x._id)) || [] $: groupApps = $apps.filter(x => group?.apps.includes(x.appId)) + $: { + if (loaded && !group?._id) { + $goto("./") + } + } async function addAll() { selectedUsers = [...selectedUsers, ...filtered.map(u => u._id)] diff --git a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte index df44a1a333..b8e0bb3df2 100644 --- a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte @@ -73,9 +73,7 @@ onMount(async () => { try { - if ($auth.groupsEnabled) { - await groups.actions.init() - } + await groups.actions.init() } catch (error) { notifications.error("Error getting user groups") } diff --git a/packages/builder/src/stores/portal/groups.js b/packages/builder/src/stores/portal/groups.js index ca814ac057..8d9f6fa132 100644 --- a/packages/builder/src/stores/portal/groups.js +++ b/packages/builder/src/stores/portal/groups.js @@ -1,7 +1,6 @@ import { writable, get } from "svelte/store" import { API } from "api" import { auth } from "stores/portal" -import { Constants } from "@budibase/frontend-core" export function createGroupsStore() { const store = writable([]) @@ -10,9 +9,7 @@ export function createGroupsStore() { init: async () => { // only init if these is a groups license, just to be sure but the feature will be blocked // on the backend anyway - if ( - get(auth).user.license.features.includes(Constants.Features.USER_GROUPS) - ) { + if (get(auth).groupsEnabled) { const users = await API.getGroups() store.set(users) }