Now correctly redirect to /@your_page or / when login
This commit is contained in:
@@ -71,9 +71,11 @@ export const useAuthStore = defineStore(
|
||||
token: accessToken
|
||||
})
|
||||
updateTokens(response.data)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
cleanTokens()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user