2019-07-23 01:31:43 +02:00
|
|
|
<template lang="pug">
|
2019-10-23 01:17:22 +02:00
|
|
|
el-main
|
|
|
|
h4 <nuxt-link to='/'><img src='/favicon.ico'/></nuxt-link> {{$t('common.set_password')}}
|
2019-07-23 01:31:43 +02:00
|
|
|
|
2019-10-20 14:22:55 +02:00
|
|
|
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'
|
|
|
|
:disabled='!new_password' @click='change_password') {{$t('common.send')}}
|
|
|
|
|
|
|
|
div(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 }
|
2019-09-06 11:58:11 +02:00
|
|
|
} 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 () {
|
|
|
|
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-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>
|