mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #2994 from gradido/preserve-email-on-login
feat(frontend): preserve email after login
This commit is contained in:
commit
a77a3e89bb
@ -29,10 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div data-test="navbar-item-username">{{ username.username }}</div>
|
<div data-test="navbar-item-username">{{ username.username }}</div>
|
||||||
|
<div data-test="navbar-item-email">{{ $store.state.email }}</div>
|
||||||
<div data-test="navbar-item-email">
|
|
||||||
{{ $store.state.email }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|||||||
@ -146,6 +146,10 @@ describe('Login', () => {
|
|||||||
expect(mockStoreDispach).toBeCalledWith('login', 'token')
|
expect(mockStoreDispach).toBeCalledWith('login', 'token')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('commits email to store', () => {
|
||||||
|
expect(mockStoreCommit).toBeCalledWith('email', 'user@example.org')
|
||||||
|
})
|
||||||
|
|
||||||
it('hides the spinner', () => {
|
it('hides the spinner', () => {
|
||||||
expect(spinnerHideMock).toBeCalled()
|
expect(spinnerHideMock).toBeCalled()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -100,6 +100,7 @@ export default {
|
|||||||
data: { login },
|
data: { login },
|
||||||
} = result
|
} = result
|
||||||
this.$store.dispatch('login', login)
|
this.$store.dispatch('login', login)
|
||||||
|
this.$store.commit('email', this.form.email)
|
||||||
await loader.hide()
|
await loader.hide()
|
||||||
if (this.$route.params.code) {
|
if (this.$route.params.code) {
|
||||||
this.$router.push(`/redeem/${this.$route.params.code}`)
|
this.$router.push(`/redeem/${this.$route.params.code}`)
|
||||||
|
|||||||
@ -53,6 +53,9 @@ export const mutations = {
|
|||||||
hideAmountGDT: (state, hideAmountGDT) => {
|
hideAmountGDT: (state, hideAmountGDT) => {
|
||||||
state.hideAmountGDT = !!hideAmountGDT
|
state.hideAmountGDT = !!hideAmountGDT
|
||||||
},
|
},
|
||||||
|
email: (state, email) => {
|
||||||
|
state.email = email || ''
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
@ -81,6 +84,7 @@ export const actions = {
|
|||||||
commit('isAdmin', false)
|
commit('isAdmin', false)
|
||||||
commit('hideAmountGDD', false)
|
commit('hideAmountGDD', false)
|
||||||
commit('hideAmountGDT', true)
|
commit('hideAmountGDT', true)
|
||||||
|
commit('email', '')
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -109,6 +113,7 @@ try {
|
|||||||
publisherId: null,
|
publisherId: null,
|
||||||
hideAmountGDD: null,
|
hideAmountGDD: null,
|
||||||
hideAmountGDT: null,
|
hideAmountGDT: null,
|
||||||
|
email: '',
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
// Syncronous mutation of the state
|
// Syncronous mutation of the state
|
||||||
|
|||||||
@ -33,6 +33,7 @@ const {
|
|||||||
hasElopage,
|
hasElopage,
|
||||||
hideAmountGDD,
|
hideAmountGDD,
|
||||||
hideAmountGDT,
|
hideAmountGDT,
|
||||||
|
email,
|
||||||
} = mutations
|
} = mutations
|
||||||
const { login, logout } = actions
|
const { login, logout } = actions
|
||||||
|
|
||||||
@ -166,6 +167,14 @@ describe('Vuex store', () => {
|
|||||||
expect(state.hideAmountGDT).toEqual(true)
|
expect(state.hideAmountGDT).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('email', () => {
|
||||||
|
it('sets the state of email', () => {
|
||||||
|
const state = { email: '' }
|
||||||
|
email(state, 'peter@luatig.de')
|
||||||
|
expect(state.email).toEqual('peter@luatig.de')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
@ -253,9 +262,9 @@ describe('Vuex store', () => {
|
|||||||
const commit = jest.fn()
|
const commit = jest.fn()
|
||||||
const state = {}
|
const state = {}
|
||||||
|
|
||||||
it('calls eleven commits', () => {
|
it('calls twelve commits', () => {
|
||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenCalledTimes(11)
|
expect(commit).toHaveBeenCalledTimes(12)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits token', () => {
|
it('commits token', () => {
|
||||||
@ -312,6 +321,12 @@ describe('Vuex store', () => {
|
|||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenNthCalledWith(11, 'hideAmountGDT', true)
|
expect(commit).toHaveBeenNthCalledWith(11, 'hideAmountGDT', true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('commits email', () => {
|
||||||
|
logout({ commit, state })
|
||||||
|
expect(commit).toHaveBeenNthCalledWith(12, 'email', '')
|
||||||
|
})
|
||||||
|
|
||||||
// how to get this working?
|
// how to get this working?
|
||||||
it.skip('calls localStorage.clear()', () => {
|
it.skip('calls localStorage.clear()', () => {
|
||||||
const clearStorageMock = jest.fn()
|
const clearStorageMock = jest.fn()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user