update authFlow
This commit is contained in:
parent
4e1e6d9cc8
commit
0d31704c95
|
@ -20,7 +20,7 @@ const LoginForm = {
|
|||
)
|
||||
},
|
||||
methods: {
|
||||
...mapMutations('authFlow', ['requireMFA', 'setupMFA']),
|
||||
...mapMutations('authFlow', ['requireMFA']),
|
||||
...mapActions({ login: 'authFlow/login' }),
|
||||
submit () {
|
||||
this.isTokenMethod ? this.submitToken() : this.submitPassword()
|
||||
|
@ -50,8 +50,7 @@ const LoginForm = {
|
|||
).then((result) => {
|
||||
if (result.error) {
|
||||
if (result.error === 'mfa_required') {
|
||||
this.setupMFA({app: app, settings: result})
|
||||
this.requireMFA()
|
||||
this.requireMFA({app: app, settings: result})
|
||||
} else {
|
||||
this.error = result.error
|
||||
this.focusOnPasswordInput()
|
||||
|
|
|
@ -7,18 +7,13 @@ const RECOVERY_STRATEGY = 'recovery'
|
|||
|
||||
|
||||
const fetchStrategy = (state, rootState) => {
|
||||
if (state.requiredMFA) {
|
||||
return state.strategy || TOTP_STRATEGY
|
||||
} else {
|
||||
return state.strategy || rootState.instance.loginMethod || PASSWORD_STRATEGY
|
||||
}
|
||||
return state.strategy || rootState.instance.loginMethod || PASSWORD_STRATEGY
|
||||
}
|
||||
|
||||
// initial state
|
||||
const state = {
|
||||
app: null,
|
||||
settings: {},
|
||||
requiredMFA: false,
|
||||
strategy: null
|
||||
}
|
||||
|
||||
|
@ -37,12 +32,10 @@ const getters = {
|
|||
return fetchStrategy(state, rootState) === TOKEN_STRATEGY
|
||||
},
|
||||
requiredTOTP: (state, getters, rootState) => {
|
||||
return state.requiredMFA &&
|
||||
fetchStrategy(state, rootState) === TOTP_STRATEGY
|
||||
return fetchStrategy(state, rootState) === TOTP_STRATEGY
|
||||
},
|
||||
requiredRecovery: (state, getters, rootState) => {
|
||||
return state.requiredMFA &&
|
||||
fetchStrategy(state, rootState) === RECOVERY_STRATEGY
|
||||
return fetchStrategy(state, rootState) === RECOVERY_STRATEGY
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,12 +47,9 @@ const mutations = {
|
|||
requireToken (state) {
|
||||
state.strategy = TOKEN_STRATEGY
|
||||
},
|
||||
setupMFA (state, {app, settings}) { // sets MFA settings (token, supported strategies)
|
||||
requireMFA (state, {app, settings}) {
|
||||
state.settings = settings
|
||||
state.app = app
|
||||
},
|
||||
requireMFA (state) {
|
||||
state.requiredMFA = true
|
||||
state.strategy = TOTP_STRATEGY
|
||||
},
|
||||
requireRecovery (state) {
|
||||
|
@ -69,7 +59,6 @@ const mutations = {
|
|||
state.strategy = TOTP_STRATEGY
|
||||
},
|
||||
reset (state) {
|
||||
state.requiredMFA = false
|
||||
state.strategy = null
|
||||
state.settings = {}
|
||||
state.app = null
|
||||
|
|
Loading…
Reference in New Issue