From e09af27909a5d039030f3cb2252fabdf37a6ac60 Mon Sep 17 00:00:00 2001 From: ='fauz <='fauzgabriel@gmail.com> Date: Thu, 30 Oct 2025 15:26:07 +0700 Subject: [PATCH] auth --- src/router/index.js | 3 ++- src/stores/auth.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 6314184..e238667 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -59,6 +59,7 @@ router.beforeEach(async(to, from, next) => { console.log("Token tidak valid / expired."); } } + const isLoggedIn = auth.isLoggedIn; // const isLoggedIn = auth.isLoggedIn; // console.log(isLoggedIn) @@ -69,7 +70,7 @@ router.beforeEach(async(to, from, next) => { // return next('/') // } - if (to.meta.requiresAuth && !auth.isLoggedIn) { + if (to.meta.requiresAuth && !isLoggedIn) { return next("/login"); } diff --git a/src/stores/auth.js b/src/stores/auth.js index b68ef37..c4b5073 100644 --- a/src/stores/auth.js +++ b/src/stores/auth.js @@ -11,7 +11,7 @@ export const useAuthStore = defineStore('auth', { user: null }), getters: { - isLoggedIn: (state) => !!state.user !== null, + isLoggedIn: (state) => !!state.user, // isLoggedIn: (state) => !!state.token && !!state.user, }, actions: {