mfa: fix login and recovery form
This commit is contained in:
parent
3cc6f80628
commit
f70fe28f64
3 changed files with 22 additions and 11 deletions
|
@ -8,18 +8,23 @@ export default {
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
authApp: 'authFlow/app',
|
|
||||||
authSettings: 'authFlow/settings'
|
authSettings: 'authFlow/settings'
|
||||||
}),
|
}),
|
||||||
...mapState({ instance: 'instance' })
|
...mapState({
|
||||||
|
instance: 'instance',
|
||||||
|
oauth: 'oauth'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
|
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
|
||||||
...mapActions({ login: 'authFlow/login' }),
|
...mapActions({ login: 'authFlow/login' }),
|
||||||
clearError () { this.error = false },
|
clearError () { this.error = false },
|
||||||
submit () {
|
submit () {
|
||||||
|
const { clientId, clientSecret } = this.oauth
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
app: this.authApp,
|
clientId,
|
||||||
|
clientSecret,
|
||||||
instance: this.instance.server,
|
instance: this.instance.server,
|
||||||
mfaToken: this.authSettings.mfa_token,
|
mfaToken: this.authSettings.mfa_token,
|
||||||
code: this.code
|
code: this.code
|
||||||
|
|
|
@ -10,15 +10,21 @@ export default {
|
||||||
authApp: 'authFlow/app',
|
authApp: 'authFlow/app',
|
||||||
authSettings: 'authFlow/settings'
|
authSettings: 'authFlow/settings'
|
||||||
}),
|
}),
|
||||||
...mapState({ instance: 'instance' })
|
...mapState({
|
||||||
|
instance: 'instance',
|
||||||
|
oauth: 'oauth'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
|
...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
|
||||||
...mapActions({ login: 'authFlow/login' }),
|
...mapActions({ login: 'authFlow/login' }),
|
||||||
clearError () { this.error = false },
|
clearError () { this.error = false },
|
||||||
submit () {
|
submit () {
|
||||||
|
const { clientId, clientSecret } = this.oauth
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
app: this.authApp,
|
clientId,
|
||||||
|
clientSecret,
|
||||||
instance: this.instance.server,
|
instance: this.instance.server,
|
||||||
mfaToken: this.authSettings.mfa_token,
|
mfaToken: this.authSettings.mfa_token,
|
||||||
code: this.code
|
code: this.code
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
const verifyOTPCode = ({ app, instance, mfaToken, code }) => {
|
const verifyOTPCode = ({ clientId, clientSecret, instance, mfaToken, code }) => {
|
||||||
const url = `${instance}/oauth/mfa/challenge`
|
const url = `${instance}/oauth/mfa/challenge`
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
form.append('client_id', app.client_id)
|
form.append('client_id', clientId)
|
||||||
form.append('client_secret', app.client_secret)
|
form.append('client_secret', clientSecret)
|
||||||
form.append('mfa_token', mfaToken)
|
form.append('mfa_token', mfaToken)
|
||||||
form.append('code', code)
|
form.append('code', code)
|
||||||
form.append('challenge_type', 'totp')
|
form.append('challenge_type', 'totp')
|
||||||
|
@ -14,12 +14,12 @@ const verifyOTPCode = ({ app, instance, mfaToken, code }) => {
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifyRecoveryCode = ({ app, instance, mfaToken, code }) => {
|
const verifyRecoveryCode = ({ clientId, clientSecret, instance, mfaToken, code }) => {
|
||||||
const url = `${instance}/oauth/mfa/challenge`
|
const url = `${instance}/oauth/mfa/challenge`
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
form.append('client_id', app.client_id)
|
form.append('client_id', clientId)
|
||||||
form.append('client_secret', app.client_secret)
|
form.append('client_secret', clientSecret)
|
||||||
form.append('mfa_token', mfaToken)
|
form.append('mfa_token', mfaToken)
|
||||||
form.append('code', code)
|
form.append('code', code)
|
||||||
form.append('challenge_type', 'recovery')
|
form.append('challenge_type', 'recovery')
|
||||||
|
|
Loading…
Reference in a new issue