Now correctly redirect to /@your_page or / when login

This commit is contained in:
2024-10-07 18:55:41 -04:00
parent a02695c81a
commit b0443fb738
4 changed files with 16 additions and 22 deletions

View File

@@ -71,9 +71,11 @@ export const useAuthStore = defineStore(
token: accessToken
})
updateTokens(response.data)
return true
} catch (error) {
console.error(error)
cleanTokens()
return false
}
}

View File

@@ -3,17 +3,28 @@ import {defineStore} from 'pinia'
import {useAuthStore} from "@/stores/authStore.js";
import {useClient} from "@/plugins/api.js";
import {useSessionStorage} from "@vueuse/core";
import {useRouter} from "vue-router";
export const useCreatorProfileStore = defineStore(
'creator-profile',
() => {
const router = useRouter()
const authStore = useAuthStore()
const authWatcher = watch(
watch(
() => authStore.isAuthenticated,
async (newValue) => {
if (newValue) {
await fetchCurrentCreatorProfile()
if (value.value === undefined) {
await router.push('/')
} else {
await router.push(`/@${value.value.name}`)
}
} else {
value.value = undefined
}