Fix routing when logged out

This commit is contained in:
Filip Rojek 2024-01-10 15:36:59 +01:00
parent f8559b477b
commit 92960c4fa7

View File

@ -5,10 +5,8 @@ import LoginView from '../views/LoginView.vue'
import userAPIS from '../api/user'
const authGuard = async () => {
console.log('1tady')
const data = await userAPIS.getUserStatus()
if (!data.data) {
console.log('tady')
throw router.push('/')
}
}
@ -59,7 +57,9 @@ router.beforeEach(async (to, from, next) => {
if (requiresAuth) {
const userStatus = await userAPIS.getUserStatus()
if (!userStatus.data) {
throw router.push('/login')
router.replace('/login')
next()
return
}
}