2020-01-24 00:50:50 +01:00
|
|
|
<template lang='pug'>
|
2021-11-10 11:00:41 +01:00
|
|
|
v-container
|
2020-07-28 12:24:39 +02:00
|
|
|
v-row.mt-5(align='center' justify='center')
|
|
|
|
v-col(cols='12' md="6" lg="5" xl="4")
|
|
|
|
v-card
|
2021-12-03 16:19:50 +01:00
|
|
|
v-card-title {{$t('common.recover_password')}}
|
|
|
|
template(v-if='user')
|
|
|
|
v-card-subtitle {{user.email}}
|
|
|
|
v-card-text
|
2020-07-28 12:24:39 +02:00
|
|
|
v-text-field(type='password'
|
2020-09-05 01:21:47 +02:00
|
|
|
:rules="$validators.password"
|
2020-07-28 12:24:39 +02:00
|
|
|
autofocus :placeholder='$t("common.new_password")'
|
|
|
|
v-model='new_password')
|
2021-12-03 16:19:50 +01:00
|
|
|
div(v-else) {{$t('recover.not_valid_code')}}
|
2019-09-11 19:12:24 +02:00
|
|
|
|
2020-07-28 12:24:39 +02:00
|
|
|
v-card-actions
|
2020-09-05 01:21:47 +02:00
|
|
|
v-spacer
|
2021-12-03 16:19:50 +01:00
|
|
|
v-btn(v-if='user' text color='primary' @click='change_password') {{$t('common.send')}}
|
2019-05-30 12:12:51 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2020-01-24 00:50:50 +01:00
|
|
|
import { mapState } from 'vuex'
|
2019-05-30 12:12:51 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Recover',
|
2019-09-11 19:12:24 +02:00
|
|
|
async asyncData ({ params, $axios }) {
|
2019-05-30 12:12:51 +02:00
|
|
|
const code = params.code
|
|
|
|
try {
|
2021-12-03 16:19:50 +01:00
|
|
|
const user = await $axios.$post('/user/check_recover_code', { recover_code: code })
|
|
|
|
return { user, code }
|
2019-09-11 19:12:24 +02:00
|
|
|
} catch (e) {
|
2021-12-03 16:19:50 +01:00
|
|
|
return { user: false }
|
2019-05-30 12:12:51 +02:00
|
|
|
}
|
|
|
|
},
|
2020-01-24 00:50:50 +01:00
|
|
|
data () {
|
2020-09-05 01:21:47 +02:00
|
|
|
return { new_password: '' }
|
2020-01-24 00:50:50 +01:00
|
|
|
},
|
|
|
|
computed: mapState(['settings']),
|
2019-05-30 12:12:51 +02:00
|
|
|
methods: {
|
|
|
|
async change_password () {
|
|
|
|
try {
|
2019-10-28 17:33:20 +01: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')
|
2020-01-15 23:53:15 +01:00
|
|
|
this.$router.replace('/login')
|
2019-09-11 19:12:24 +02:00
|
|
|
} catch (e) {
|
2020-10-07 11:12:13 +02:00
|
|
|
this.$root.$message(e, { color: 'warning' })
|
2019-05-30 12:12:51 +02:00
|
|
|
}
|
|
|
|
}
|
2020-01-24 00:50:50 +01:00
|
|
|
},
|
|
|
|
head () {
|
|
|
|
return { title: `${this.settings.title} - Authorize` }
|
2019-05-30 12:12:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2021-10-18 11:31:44 +02:00
|
|
|
<style>
|
2020-01-24 00:50:50 +01:00
|
|
|
h4 img {
|
|
|
|
max-height: 40px;
|
|
|
|
border-radius: 20px;
|
|
|
|
background-color: #333;
|
|
|
|
border: 1px solid #333;
|
|
|
|
}
|
|
|
|
</style>
|