add abortMFA

This commit is contained in:
Maksim Pechnikov 2019-06-08 15:33:49 +03:00
parent f1e8edab11
commit 30f054a628
5 changed files with 17 additions and 7 deletions

View File

@ -14,7 +14,7 @@ export default {
...mapState({ instance: 'instance' })
},
methods: {
...mapMutations({ requireTOTP: 'authFlow/requireTOTP' }),
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
...mapActions({ login: 'authFlow/login' }),
clearError () { this.error = false },
submit () {

View File

@ -17,6 +17,9 @@
<a href="#" @click.prevent="requireTOTP">
{{$t('login.enter_two_factor_code')}}
</a>
<a href="#" @click.prevent="abortMFA">
{{$t('general.cancel')}}
</a>
</div>
<button type='submit' class='btn btn-default'>
{{$t('general.verify')}}

View File

@ -13,7 +13,7 @@ export default {
...mapState({ instance: 'instance' })
},
methods: {
...mapMutations({ requireRecovery: 'authFlow/requireRecovery' }),
...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
...mapActions({ login: 'authFlow/login' }),
clearError () { this.error = false },
submit () {

View File

@ -21,6 +21,9 @@
<a href="#" @click.prevent="requireRecovery">
{{$t('login.enter_recovery_code')}}
</a>
<a href="#" @click.prevent="abortMFA">
{{$t('general.cancel')}}
</a>
</div>
<button type='submit' class='btn btn-default'>
{{$t('general.verify')}}

View File

@ -13,6 +13,12 @@ const state = {
initStrategy: PASSWORD_STRATEGY // default strategy from config
}
const resetState = (state) => {
state.strategy = state.initStrategy
state.settings = {}
state.app = null
}
// getters
const getters = {
app: (state, getters) => {
@ -60,10 +66,8 @@ const mutations = {
requireTOTP (state) {
state.strategy = TOTP_STRATEGY
},
reset (state) {
state.strategy = state.initStrategy
state.settings = {}
state.app = null
abortMFA (state) {
resetState(state)
}
}
@ -72,7 +76,7 @@ const actions = {
async login ({state, dispatch, commit}, {access_token}) {
commit('setToken', access_token, { root: true })
await dispatch('loginUser', access_token, { root: true })
commit('reset')
resetState(state)
}
}