Fix an error when logging out was causing state issues
This commit is contained in:
@@ -9,8 +9,10 @@ export const useAuthStore = defineStore(
|
||||
() => {
|
||||
const clientApi = useClient()
|
||||
const router = useRouter()
|
||||
|
||||
const accessToken = useSessionStorage('auth-accessToken', undefined)
|
||||
const refreshToken = useSessionStorage('auth-refreshToken', undefined)
|
||||
|
||||
const isAuthenticated = computed(() => !!accessToken.value)
|
||||
|
||||
function updateTokens(data) {
|
||||
@@ -25,9 +27,9 @@ export const useAuthStore = defineStore(
|
||||
})
|
||||
}
|
||||
|
||||
function logout() {
|
||||
async function logout() {
|
||||
cleanTokens()
|
||||
router.push('/')
|
||||
await router.push('/')
|
||||
}
|
||||
|
||||
async function login(email, password) {
|
||||
|
||||
@@ -10,7 +10,7 @@ export const useUserStore = defineStore(
|
||||
const authStore = useAuthStore()
|
||||
const authWatcher = watch(
|
||||
() => authStore.isAuthenticated,
|
||||
async (newValue, oldValue) => {
|
||||
async (newValue) => {
|
||||
if (newValue) {
|
||||
await fetchCurrentUserProfile()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user