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) => {
|
const addNavigationGuards = (router, store) => {
|
||||||
// store token on authenticate
|
// store token on authenticate
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log('token', to.path, from.path, to.query)
|
|
||||||
// handle authentication
|
|
||||||
if (to.path === '/authenticate' && to.query.token) {
|
if (to.path === '/authenticate' && to.query.token) {
|
||||||
console.log('token', to.query.token, to)
|
|
||||||
store.commit('token',to.query.token)
|
store.commit('token',to.query.token)
|
||||||
// to.query = {}
|
|
||||||
next({path: '/'})
|
next({path: '/'})
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
@ -17,7 +13,7 @@ const addNavigationGuards = (router, store) => {
|
|||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log('protect', to.path, from.path)
|
console.log('protect', to.path, from.path)
|
||||||
// handle authentication
|
// 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' })
|
next({ path: '/not-found' })
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
|||||||
@ -6,6 +6,11 @@ const routes = [
|
|||||||
path: '/',
|
path: '/',
|
||||||
component: () => import('@/pages/Overview.vue'),
|
component: () => import('@/pages/Overview.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// TODO: Implement a "You are logged out"-Page
|
||||||
|
path: '/logout',
|
||||||
|
component: () => import('@/components/NotFoundPage.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
component: () => import('@/pages/UserSearch.vue'),
|
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({
|
const store = new Vuex.Store({
|
||||||
plugins: [
|
plugins: [
|
||||||
createPersistedState({
|
createPersistedState({
|
||||||
@ -32,6 +39,7 @@ const store = new Vuex.Store({
|
|||||||
},
|
},
|
||||||
// Syncronous mutation of the state
|
// Syncronous mutation of the state
|
||||||
mutations,
|
mutations,
|
||||||
|
actions,
|
||||||
})
|
})
|
||||||
|
|
||||||
export default store
|
export default store
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user