From bf5dbca5aa5faa71477c39f6669fef4c4e8cb2a4 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Tue, 13 Aug 2024 13:10:19 +0200 Subject: [PATCH] docs(auth): add a logging step and remove extra notes build_image --- middleware/auth.global.ts | 6 ++++-- services/application-service.ts | 2 -- stores/auth.ts | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts index fe5c9d8..3e7e959 100644 --- a/middleware/auth.global.ts +++ b/middleware/auth.global.ts @@ -5,6 +5,7 @@ const authFlowRoutes = [ "/auth/callback", "/auth/silent-refresh", "/auth/logout", + "/", ]; export default defineNuxtRouteMiddleware(async (to, from) => { @@ -14,8 +15,9 @@ export default defineNuxtRouteMiddleware(async (to, from) => { if (!user && !authFlowRoutes.includes(to.path)) { // use this to automatically force a sign in and redirect - // services.$auth.signInRedirect(); + console.warn("Not logged in"); + return await services.$auth.signInRedirect(); } else { - authStore.setUpUserCredentials(user); + return authStore.setUpUserCredentials(user); } }); diff --git a/services/application-service.ts b/services/application-service.ts index f38fcc4..8b90c1a 100644 --- a/services/application-service.ts +++ b/services/application-service.ts @@ -8,6 +8,4 @@ export default class ApplicationService { getToken() { return this.accessToken; } - - // use this to add to API calls or the like } diff --git a/stores/auth.ts b/stores/auth.ts index 2a760c8..7aa9954 100644 --- a/stores/auth.ts +++ b/stores/auth.ts @@ -30,6 +30,7 @@ export const useAuth = defineStore("auth", () => { }; }); +// Allows changes made to the store code to be applied automatically without having to restart the app if (import.meta.hot) { import.meta.hot.accept(acceptHMRUpdate(useAuth, import.meta.hot)); }