mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
logout page
This commit is contained in:
parent
967864d989
commit
c057df54cf
@ -1,12 +1,8 @@
|
||||
const addNavigationGuards = (router, store) => {
|
||||
// store token on authenticate
|
||||
router.beforeEach((to, from, next) => {
|
||||
console.log('token', to.path, from.path, to.query)
|
||||
// handle authentication
|
||||
if (to.path === '/authenticate' && to.query.token) {
|
||||
console.log('token', to.query.token, to)
|
||||
store.commit('token',to.query.token)
|
||||
// to.query = {}
|
||||
next({path: '/'})
|
||||
} else {
|
||||
next()
|
||||
@ -17,7 +13,7 @@ const addNavigationGuards = (router, store) => {
|
||||
router.beforeEach((to, from, next) => {
|
||||
console.log('protect', to.path, from.path)
|
||||
// handle authentication
|
||||
if (!store.state.token && to.path !== '/not-found') {
|
||||
if (!store.state.token && to.path !== '/not-found' && to.path !== '/logout') {
|
||||
next({ path: '/not-found' })
|
||||
} else {
|
||||
next()
|
||||
|
||||
@ -6,6 +6,11 @@ const routes = [
|
||||
path: '/',
|
||||
component: () => import('@/pages/Overview.vue'),
|
||||
},
|
||||
{
|
||||
// TODO: Implement a "You are logged out"-Page
|
||||
path: '/logout',
|
||||
component: () => import('@/components/NotFoundPage.vue'),
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
component: () => import('@/pages/UserSearch.vue'),
|
||||
|
||||
@ -19,6 +19,13 @@ export const mutations = {
|
||||
}
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
logout: ({ commit, state }) => {
|
||||
commit('token', null)
|
||||
localStorage.clear()
|
||||
},
|
||||
}
|
||||
|
||||
const store = new Vuex.Store({
|
||||
plugins: [
|
||||
createPersistedState({
|
||||
@ -32,6 +39,7 @@ const store = new Vuex.Store({
|
||||
},
|
||||
// Syncronous mutation of the state
|
||||
mutations,
|
||||
actions,
|
||||
})
|
||||
|
||||
export default store
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user