Fix an error when logging out was causing state issues

This commit is contained in:
Jonathan Bourdon
2024-08-05 13:17:22 -04:00
parent 9cbf63339a
commit 3a98b38a71
5 changed files with 12 additions and 11 deletions

View File

@@ -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) {

View File

@@ -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 {