2019-06-12 13:16:55 -07:00
|
|
|
import mfaApi from '../../services/new_api/mfa.js'
|
|
|
|
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
|
2020-10-20 11:18:23 -07:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faTimes
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faTimes
|
|
|
|
)
|
2019-06-12 13:16:55 -07:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data: () => ({
|
|
|
|
code: null,
|
|
|
|
error: false
|
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
authSettings: 'authFlow/settings'
|
|
|
|
}),
|
2019-12-11 21:42:21 -08:00
|
|
|
...mapState({
|
|
|
|
instance: 'instance',
|
|
|
|
oauth: 'oauth'
|
|
|
|
})
|
2019-06-12 13:16:55 -07:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),
|
|
|
|
...mapActions({ login: 'authFlow/login' }),
|
|
|
|
clearError () { this.error = false },
|
|
|
|
submit () {
|
2019-12-11 21:42:21 -08:00
|
|
|
const { clientId, clientSecret } = this.oauth
|
|
|
|
|
2019-06-12 13:16:55 -07:00
|
|
|
const data = {
|
2019-12-11 21:42:21 -08:00
|
|
|
clientId,
|
|
|
|
clientSecret,
|
2019-06-12 13:16:55 -07:00
|
|
|
instance: this.instance.server,
|
|
|
|
mfaToken: this.authSettings.mfa_token,
|
|
|
|
code: this.code
|
|
|
|
}
|
|
|
|
|
|
|
|
mfaApi.verifyRecoveryCode(data).then((result) => {
|
|
|
|
if (result.error) {
|
|
|
|
this.error = result.error
|
|
|
|
this.code = null
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.login(result).then(() => {
|
2019-07-05 00:02:14 -07:00
|
|
|
this.$router.push({ name: 'friends' })
|
2019-06-12 13:16:55 -07:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|