From 2352631aca5823afdcea25f9dc8322a2344e627b Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Mon, 13 Nov 2023 23:51:39 +0530 Subject: [PATCH] chore: simplify stores/auth exports --- desk/src/router/index.js | 2 +- desk/src/stores/auth.ts | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/desk/src/router/index.js b/desk/src/router/index.js index d532cd651..2d2cdf560 100644 --- a/desk/src/router/index.js +++ b/desk/src/router/index.js @@ -198,7 +198,7 @@ router.beforeEach(async (to) => { await initTelemetry(); await authStore.init(); - if (isAuthRoute) { + if ((to.meta.agent && !authStore.hasDeskAccess) || isAuthRoute) { router.replace({ name: WEBSITE_ROOT }); } } catch { diff --git a/desk/src/stores/auth.ts b/desk/src/stores/auth.ts index e2e52d810..d53d4af13 100644 --- a/desk/src/stores/auth.ts +++ b/desk/src/stores/auth.ts @@ -20,6 +20,8 @@ export const useAuthStore = defineStore("auth", () => { const userInfo = createResource({ url: URI_USER_INFO, }); + const init = userInfo.fetch; + const reloadUser = userInfo.reload; const user__ = computed(() => userInfo.data || {}); const hasDeskAccess: ComputedRef = computed( @@ -75,14 +77,6 @@ export const useAuthStore = defineStore("auth", () => { call(URI_LOGOUT).then(() => router.push({ name: LOGIN })); } - function reloadUser() { - userInfo.reload(); - } - - async function init() { - await userInfo.fetch(); - } - return { hasDeskAccess, init,