aboutsummaryrefslogtreecommitdiff
path: root/src/components/mfa_form/totp_form.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/mfa_form/totp_form.js')
-rw-r--r--src/components/mfa_form/totp_form.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/components/mfa_form/totp_form.js b/src/components/mfa_form/totp_form.js
new file mode 100644
index 00000000..6c94fe52
--- /dev/null
+++ b/src/components/mfa_form/totp_form.js
@@ -0,0 +1,40 @@
+import mfaApi from '../../services/new_api/mfa.js'
+import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
+export default {
+ data: () => ({
+ code: null,
+ error: false
+ }),
+ computed: {
+ ...mapGetters({
+ authApp: 'authFlow/app',
+ authSettings: 'authFlow/settings'
+ }),
+ ...mapState({ instance: 'instance' })
+ },
+ methods: {
+ ...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
+ ...mapActions({ login: 'authFlow/login' }),
+ clearError () { this.error = false },
+ submit () {
+ const data = {
+ app: this.authApp,
+ instance: this.instance.server,
+ mfaToken: this.authSettings.mfa_token,
+ code: this.code
+ }
+
+ mfaApi.verifyOTPCode(data).then((result) => {
+ if (result.error) {
+ this.error = result.error
+ this.code = null
+ return
+ }
+
+ this.login(result).then(() => {
+ this.$router.push({name: 'friends'})
+ })
+ })
+ }
+ }
+}