admin-profile.component.js 1.08 KB
Newer Older
1 2 3 4
'use strict'

export default {
  name: 'admin-profile',
NGPixel's avatar
NGPixel committed
5
  props: ['email', 'name', 'provider', 'tfaIsActive'],
6 7 8 9 10 11
  data() {
    return {
      password: '********',
      passwordVerify: '********'
    }
  },
NGPixel's avatar
NGPixel committed
12 13 14 15 16
  computed: {
    tfaStatus() {
      return this.tfaIsActive ? this.$t('profile.tfaenabled') : this.$t('profile.tfadisabled')
    }
  },
17 18
  methods: {
    saveUser() {
19
      let self = this
20
      if (this.password !== this.passwordVerify) {
21 22 23 24 25
        return self.$store.dispatch('alert', {
          style: 'red',
          icon: 'square-cross',
          msg: 'The passwords don\'t match. Try again.'
        })
26
      }
27
      this.$http.post(window.location.href, {
28 29
        password: this.password,
        name: this.name
30 31 32 33 34 35 36 37 38 39 40 41
      }).then(resp => {
        self.$store.dispatch('alert', {
          style: 'green',
          icon: 'check',
          msg: 'Changes have been applied successfully.'
        })
      }).catch(err => {
        self.$store.dispatch('alert', {
          style: 'red',
          icon: 'square-cross',
          msg: 'Error: ' + err.body.msg
        })
42 43 44 45
      })
    }
  }
}