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)); }