gancio/pages/user_confirm/_code.vue

50 lines
1.4 KiB
Vue
Raw Normal View History

2019-07-23 01:31:43 +02:00
<template lang="pug">
2021-11-10 11:00:41 +01:00
v-container
2020-08-05 17:30:41 +02:00
v-row.mt-5(align='center' justify='center')
v-col(cols='12' md="6" lg="5" xl="4")
v-card
v-card-title {{$t('common.set_password')}}
template(v-if='user')
v-card-subtitle {{user.email}}
v-card-text
v-form
v-text-field(type='password' v-model='new_password' :label="$t('common.new_password')" :rules='$validators.password' autofocus)
2019-07-23 01:31:43 +02:00
2020-08-05 17:30:41 +02:00
v-card-actions
v-spacer
v-btn(text color="primary" :disabled='!new_password' @click='change_password') {{$t('common.send')}}
2019-10-20 14:22:55 +02:00
v-card-text(v-else)
v-alert.ma-5(type='error') {{$t('recover.not_valid_code')}}
2019-09-11 19:12:24 +02:00
2019-07-23 01:31:43 +02:00
</template>
<script>
export default {
2019-10-20 14:22:55 +02:00
name: 'Recover',
2019-09-11 19:12:24 +02:00
async asyncData ({ params, $axios }) {
2019-10-20 14:22:55 +02:00
const code = params.code
2019-07-23 01:31:43 +02:00
try {
const user = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { user, code }
} catch (e) {
return { user: false }
2019-07-23 01:31:43 +02:00
}
2019-10-20 14:22:55 +02:00
},
2020-06-01 18:04:02 +02:00
data () {
2020-09-05 01:21:47 +02:00
return { new_password: '' }
2020-06-01 18:04:02 +02:00
},
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: 'success' })
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
}
}
2019-07-23 01:31:43 +02:00
}
}
2019-10-28 17:33:20 +01:00
</script>