Skip to content

Commit

Permalink
chore: simplify stores/auth exports
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiyad committed Nov 13, 2023
1 parent fb4e3ce commit 2352631
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion desk/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 2 additions & 8 deletions desk/src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> = computed(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2352631

Please sign in to comment.