logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

totp_form.js (1215B)


  1. import mfaApi from '../../services/new_api/mfa.js'
  2. import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
  3. import { library } from '@fortawesome/fontawesome-svg-core'
  4. import {
  5. faTimes
  6. } from '@fortawesome/free-solid-svg-icons'
  7. library.add(
  8. faTimes
  9. )
  10. export default {
  11. data: () => ({
  12. code: null,
  13. error: false
  14. }),
  15. computed: {
  16. ...mapGetters({
  17. authSettings: 'authFlow/settings'
  18. }),
  19. ...mapState({
  20. instance: 'instance',
  21. oauth: 'oauth'
  22. })
  23. },
  24. methods: {
  25. ...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),
  26. ...mapActions({ login: 'authFlow/login' }),
  27. clearError () { this.error = false },
  28. submit () {
  29. const { clientId, clientSecret } = this.oauth
  30. const data = {
  31. clientId,
  32. clientSecret,
  33. instance: this.instance.server,
  34. mfaToken: this.authSettings.mfa_token,
  35. code: this.code
  36. }
  37. mfaApi.verifyOTPCode(data).then((result) => {
  38. if (result.error) {
  39. this.error = result.error
  40. this.code = null
  41. return
  42. }
  43. this.login(result).then(() => {
  44. this.$router.push({ name: 'friends' })
  45. })
  46. })
  47. }
  48. }
  49. }