diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-06-12 20:16:55 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-06-12 20:16:55 +0000 |
| commit | e53f11c30fb2eedd0a437d3cfe9592c555de6a95 (patch) | |
| tree | 560ecc4d370fda07c5da8cde5c60c679fa9c7862 /src/components/mfa_form/recovery_form.js | |
| parent | 9df99c5205b1cb560bb25c0dd81cc90acbde4d7f (diff) | |
| parent | 77eceedbf7a5b53948d7d91b3d228aa303c02081 (diff) | |
Merge branch 'feature/2fa' into 'develop'
adds 2FA/two_factor_authentication support
See merge request pleroma/pleroma-fe!556
Diffstat (limited to 'src/components/mfa_form/recovery_form.js')
| -rw-r--r-- | src/components/mfa_form/recovery_form.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/components/mfa_form/recovery_form.js b/src/components/mfa_form/recovery_form.js new file mode 100644 index 00000000..fbe9b437 --- /dev/null +++ b/src/components/mfa_form/recovery_form.js @@ -0,0 +1,41 @@ +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', ['requireTOTP', '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.verifyRecoveryCode(data).then((result) => { + if (result.error) { + this.error = result.error + this.code = null + return + } + + this.login(result).then(() => { + this.$router.push({name: 'friends'}) + }) + }) + } + } +} |
