mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
separate router.beforeach & implement the authenticate route
This commit is contained in:
parent
82356dceb4
commit
c5ec31343c
@ -1,12 +1,28 @@
|
||||
const addNavigationGuards = (router, store) => {
|
||||
// handle publisherId
|
||||
router.beforeEach((to, from, next) => {
|
||||
// handle publisherId
|
||||
const publisherId = to.query.pid
|
||||
if (publisherId) {
|
||||
store.commit('publisherId', publisherId)
|
||||
delete to.query.pid
|
||||
}
|
||||
// handle authentication
|
||||
next()
|
||||
})
|
||||
|
||||
// store token on authenticate
|
||||
router.beforeEach((to, from, next) => {
|
||||
console.log('token', to.path, from.path, to.query)
|
||||
if (to.path === '/authenticate' && to.query.token) {
|
||||
console.log('token', to.query.token, to)
|
||||
store.commit('token',to.query.token)
|
||||
next({path: '/overview'})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
// handle authentication
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.requiresAuth && !store.state.token) {
|
||||
next({ path: '/login' })
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import NotFound from '@/views/NotFoundPage.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/authenticate',
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
redirect: (to) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user