gancio-upstream/pages/user_confirm/_code.vue

52 lines
1.4 KiB
Vue
Raw Normal View History

2019-07-23 01:31:43 +02:00
<template lang="pug">
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 <nuxt-link to='/'><img src='/favicon.ico'/></nuxt-link> {{$t('common.set_password')}}
template(v-if='valid')
v-card-text(v-if='valid')
v-form(v-if='valid')
v-text-field(type='password' v-model='new_password' :label="$t('common.new_password')")
2019-07-23 01:31:43 +02:00
2020-08-05 17:30:41 +02:00
v-card-actions
v-btn(color="success" :disabled='!new_password' @click='change_password') {{$t('common.send')}}
2019-10-20 14:22:55 +02:00
2020-08-05 17:30:41 +02:00
v-card-text(v-else) {{$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 {
2019-10-20 14:22:55 +02:00
const valid = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { valid, code }
} catch (e) {
2019-07-23 01:31:43 +02:00
return { valid: false }
}
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-07-31 01:03:19 +02:00
this.$root.$message({
2019-10-20 14:22:55 +02:00
type: 'success',
message: this.$t('common.password_updated')
})
2020-01-15 23:53:15 +01:00
this.$router.replace('/login')
2019-10-20 14:22:55 +02:00
} catch (e) {
2020-07-31 01:03:19 +02:00
this.$root.$message({
2019-10-20 14:22:55 +02:00
type: 'warning',
message: e
})
}
}
2019-07-23 01:31:43 +02:00
}
}
2019-10-28 17:33:20 +01:00
</script>