finish srs system
This commit is contained in:
@@ -34,19 +34,24 @@ router.isReady().then(() => {
|
||||
localStorage.removeItem('vuetify:dynamic-reload')
|
||||
})
|
||||
|
||||
let hasFetchedUser = false
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
const auth = useAuthStore()
|
||||
if (!auth.user && !auth.loading) {
|
||||
await auth.fetchUser()
|
||||
}
|
||||
|
||||
if (to.path === '/login') return true
|
||||
|
||||
if (!hasFetchedUser && !auth.user && !auth.loading) {
|
||||
hasFetchedUser = true
|
||||
await auth.fetchUser()
|
||||
}
|
||||
|
||||
if (!auth.isAuthenticated) {
|
||||
return { path: '/login' }
|
||||
return { path: '/login', query: { redirect: to.fullPath } }
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user