gancio-upstream/pages/user_confirm_pwd/_code.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2019-10-20 14:22:55 +02:00
<template lang="pug">
el-card
nuxt-link.float-right(to='/')
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
h5 <img src='/favicon.ico'/> {{$t('common.set_password')}}
div(v-if='valid')
el-form
el-form-item {{$t('common.new_password')}}
el-input(type='password', v-model='new_password')
el-button(plain type="success" icon='el-icon-send', @click='change_password') {{$t('common.send')}}
div(v-else) {{$t('recover.not_valid_code')}}
</template>
<script>
export default {
name: 'Recover',
async asyncData ({ params, $axios }) {
const code = params.code
try {
const valid = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { valid, code }
} catch (e) {
return { valid: false }
}
},
2020-06-01 18:04:02 +02:00
data () {
return { new_password: '' }
},
2019-10-20 14:22:55 +02:00
methods: {
async change_password () {
try {
2020-06-01 18:04:02 +02:00
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
2020-10-07 11:12:13 +02:00
this.$root.$message('common.password_updated', { color: 'succes' })
2020-01-15 23:53:15 +01:00
this.$router.replace('/login')
2019-10-20 14:22:55 +02:00
} catch (e) {
2020-10-07 11:12:13 +02:00
this.$root.$message(e, { color: 'warning' })
2019-10-20 14:22:55 +02:00
}
}
}
}
</script>