This commit is contained in:
Andreani Jean
2023-07-03 23:48:26 +02:00
parent d5862cc021
commit c5ff54e1cd

View File

@@ -50,18 +50,23 @@ router.beforeEach(async (to, from, next) => {
to.name === 'my-settings' ||
to.name === 'my-sequences' ||
to.name === 'sequence'
const nextRoute = `${location.protocol}//${location.host}${to.path}`
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) {
const win: Window = window
win.location = getAuthRoute('/auth/login', to.path)
} else next()
await router.push(
`api/auth/login?next_url=${encodeURIComponent(nextRoute)}`
)
} else {
next()
}
} catch (e) {
const win: Window = window
win.location.href = getAuthRoute('/auth/login', to.path)
await router.push(
`api/auth/login?next_url=${encodeURIComponent(nextRoute)}`
)
}
} else next()
})