forked from Ivasoft/geovisio-website
test new guard router
This commit is contained in:
@@ -59,19 +59,27 @@ router.beforeEach(async (to, from, next) => {
|
||||
to.name === 'my-settings' ||
|
||||
to.name === 'my-sequences' ||
|
||||
to.name === 'sequence'
|
||||
const url = `${location.protocol}//${location.host}`
|
||||
const nextRoute = `${url}${to.path}`
|
||||
console.log(url)
|
||||
console.log(nextRoute)
|
||||
if (loggedRoutes) {
|
||||
try {
|
||||
const loginUrl = `/api/users/me`
|
||||
const isKeycloakLogout = await axios.get(loginUrl)
|
||||
const isSiteLogin = !!cookies.get('user_id')
|
||||
if (isKeycloakLogout.status >= 300 || !isSiteLogin) {
|
||||
window.location.replace(getAuthRoute('/auth/login', to.path))
|
||||
window.location.replace(
|
||||
`${url}auth/login?next_url=${encodeURIComponent(nextRoute)}`
|
||||
)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
} catch (e) {
|
||||
window.location.replace(getAuthRoute('/auth/login', to.path))
|
||||
next()
|
||||
console.log('CAAAATCH', `${url}/api/auth/login`)
|
||||
window.location.replace(
|
||||
`${url}/api/auth/login?next_url=${encodeURIComponent(nextRoute)}`
|
||||
)
|
||||
}
|
||||
} else next()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user