From 8c57ff841ec78e4221e24d8f0f41c35e3a62b87d Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 25 Mar 2023 11:07:22 -0800 Subject: [PATCH] fix: redirect issues for authorized users (#374) --- frontend/composables/use-auth-context.ts | 2 +- frontend/nuxt.config.ts | 2 +- frontend/pages/index.vue | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/composables/use-auth-context.ts b/frontend/composables/use-auth-context.ts index c39ac3f..bcffad7 100644 --- a/frontend/composables/use-auth-context.ts +++ b/frontend/composables/use-auth-context.ts @@ -106,8 +106,8 @@ class AuthContext implements IAuthContext { this._expiresAt.value = null; this._attachmentToken.value = null; - navigateTo("/"); console.log("Session invalidated"); + window.location.href = "/"; } async login(api: PublicApi, email: string, password: string, stayLoggedIn: boolean) { diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index c98f1a1..479d1f4 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -20,7 +20,7 @@ export default defineNuxtConfig({ }, devOptions: { // Enable to troubleshoot during development - enabled: true, + enabled: false, }, manifest: { name: "Homebox", diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index 614a826..2258c4c 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -8,6 +8,9 @@ }); const ctx = useAuthContext(); + if (ctx.isAuthorized()) { + navigateTo("/home"); + } const api = usePublicApi(); const toast = useNotifier(); @@ -29,10 +32,6 @@ } }); - if (!ctx.isAuthorized()) { - navigateTo("/home"); - } - const route = useRoute(); const router = useRouter();