logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe

mfa_totp.js (1136B)


      1 import Confirm from './confirm.vue'
      2 import { mapState } from 'vuex'
      3 
      4 export default {
      5   props: ['settings'],
      6   data: () => ({
      7     error: false,
      8     currentPassword: '',
      9     deactivate: false,
     10     inProgress: false // progress peform request to disable otp method
     11   }),
     12   components: {
     13     'confirm': Confirm
     14   },
     15   computed: {
     16     isActivated () {
     17       return this.settings.totp
     18     },
     19     ...mapState({
     20       backendInteractor: (state) => state.api.backendInteractor
     21     })
     22   },
     23   methods: {
     24     doActivate () {
     25       this.$emit('activate')
     26     },
     27     cancelDeactivate () { this.deactivate = false },
     28     doDeactivate () {
     29       this.error = null
     30       this.deactivate = true
     31     },
     32     confirmDeactivate () { // confirm deactivate TOTP method
     33       this.error = null
     34       this.inProgress = true
     35       this.backendInteractor.mfaDisableOTP({
     36         password: this.currentPassword
     37       })
     38         .then((res) => {
     39           this.inProgress = false
     40           if (res.error) {
     41             this.error = res.error
     42             return
     43           }
     44           this.deactivate = false
     45           this.$emit('deactivate')
     46         })
     47     }
     48   }
     49 }