mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
feat: Global Catch of Publisher ID to Store
This commit is contained in:
parent
da99d4ee4c
commit
6665c17f0b
@ -50,6 +50,11 @@ Vue.config.productionTip = false
|
||||
loadAllRules(i18n)
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const publisherId = to.query.pid
|
||||
if (publisherId) {
|
||||
store.commit('publisherId', publisherId)
|
||||
to.query.pid = undefined
|
||||
}
|
||||
if (to.meta.requiresAuth && !store.state.token) {
|
||||
next({ path: '/login' })
|
||||
} else {
|
||||
|
||||
@ -29,6 +29,9 @@ export const mutations = {
|
||||
newsletterState: (state, newsletterState) => {
|
||||
state.newsletterState = newsletterState
|
||||
},
|
||||
publisherId: (state, publisherId) => {
|
||||
state.publisherId = publisherId
|
||||
},
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
|
||||
@ -9,6 +9,7 @@ const {
|
||||
lastName,
|
||||
description,
|
||||
newsletterState,
|
||||
publisherId,
|
||||
} = mutations
|
||||
const { login, logout } = actions
|
||||
|
||||
@ -77,6 +78,14 @@ describe('Vuex store', () => {
|
||||
expect(state.newsletterState).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('publisherId', () => {
|
||||
it('sets the state of publisherId', () => {
|
||||
const state = {}
|
||||
publisherId(state, 42)
|
||||
expect(state.publisherId).toEqual(42)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('actions', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user