improve user_confirm / recover code flow

This commit is contained in:
lesion
2021-12-03 16:19:50 +01:00
parent f8d1284437
commit d68b04ff91
5 changed files with 30 additions and 23 deletions

View File

@@ -3,32 +3,32 @@ v-container
v-row.mt-5(align='center' justify='center')
v-col(cols='12' md="6" lg="5" xl="4")
v-card
v-card-title {{settings.title}} - {{$t('common.recover_password')}}
v-card-text
div(v-if='valid')
v-card-title {{$t('common.recover_password')}}
template(v-if='user')
v-card-subtitle {{user.email}}
v-card-text
v-text-field(type='password'
:rules="$validators.password"
autofocus :placeholder='$t("common.new_password")'
v-model='new_password')
div(v-else) {{$t('recover.not_valid_code')}}
div(v-else) {{$t('recover.not_valid_code')}}
v-card-actions
v-spacer
v-btn(v-if='valid' color='primary' @click='change_password') {{$t('common.send')}}
v-btn(v-if='user' text color='primary' @click='change_password') {{$t('common.send')}}
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Recover',
layout: 'modal',
async asyncData ({ params, $axios }) {
const code = params.code
try {
const valid = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { valid, code }
const user = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { user, code }
} catch (e) {
return { valid: false }
return { user: false }
}
},
data () {

View File

@@ -3,16 +3,19 @@ v-container
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='/'><v-img src='/logo.png' max-width="40px" max-height="40px" contain class='mr-4'/></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')")
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)
v-card-actions
v-btn(color="success" :disabled='!new_password' @click='change_password') {{$t('common.send')}}
v-spacer
v-btn(text color="primary" :disabled='!new_password' @click='change_password') {{$t('common.send')}}
v-card-text(v-else) {{$t('recover.not_valid_code')}}
v-card-text(v-else)
v-alert.ma-5(type='error') {{$t('recover.not_valid_code')}}
</template>
<script>
@@ -22,10 +25,10 @@ export default {
async asyncData ({ params, $axios }) {
const code = params.code
try {
const valid = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { valid, code }
const user = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { user, code }
} catch (e) {
return { valid: false }
return { user: false }
}
},
data () {