* refactoring and fixes by login

feature: #4
This commit is contained in:
2023-01-04 00:25:46 +01:00
parent 46dd4ef361
commit 1eab4c586f
15 changed files with 262 additions and 255 deletions

View File

@@ -33,8 +33,8 @@ const router = createRouter({
}
},
{
path: '/support',
name: 'support',
path: '/administration',
name: 'administration',
// this page is lazy-loaded when the route is visited.
component: () => import('../views/AdministrationView.vue'),
meta: {
@@ -87,12 +87,17 @@ const router = createRouter({
}
]
})
router.beforeEach(async (to, from, next) => {
//if user was logged in but reloaded page. So we have all data, need only restore it
if (store.state.keycloak.keycloak !== null && getKeycloak() === null) {
await keycloakSetup()
}
if (to.meta.requiresAuth === true) {
if (getKeycloak() === null) {
await keycloakSetup()
store.commit('initKeycloak', getKeycloak())
store.commit('isAnonym', false)
}
if (!getKeycloak().authenticated) {
next('/forbidden')