forked from kompetenzinventar/ki-frontend
introduce vuex
This commit is contained in:
@ -3,6 +3,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
import store from '@/store'
|
||||
|
||||
import Index from '@/views/Index.vue'
|
||||
import Search from '@/views/Search.vue'
|
||||
import Edit from '@/views/profile/Edit.vue'
|
||||
@ -16,9 +19,9 @@ const routes = [
|
||||
template: "<router-view/>",
|
||||
},
|
||||
beforeEnter: (to, from, next) => {
|
||||
if(localStorage.getItem('token') !== null){
|
||||
if (store.state.token){
|
||||
next()
|
||||
}else{
|
||||
} else {
|
||||
next({path: '/', query: {url: to.fullPath, access: false}})
|
||||
}
|
||||
},
|
||||
@ -52,4 +55,4 @@ const router = createRouter({
|
||||
routes
|
||||
})
|
||||
|
||||
export default router
|
||||
export default router
|
||||
|
Reference in New Issue
Block a user