Complete and fix Request/Reset password feature

This commit is contained in:
Bubka
2020-01-15 11:48:22 +01:00
parent 2326bc1245
commit aef68df370
4 changed files with 36 additions and 26 deletions

View File

@ -2,7 +2,7 @@
<div class="section">
<div class="columns is-mobile is-centered">
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
<h1 class="title">{{ $t('auth.reset_password') }}</h1>
<h1 class="title">{{ $t('auth.forms.reset_password') }}</h1>
<form method="POST" action="/password/email">
<div class="field">
<label class="label">{{ $t('auth.forms.email') }}</label>
@ -13,13 +13,17 @@
</div>
<div class="field is-grouped">
<div class="control">
<button type="submit" class="button is-link" @click="handleSubmit">{{ $t('auth.send_password_reset_link') }}</button>
<button type="submit" class="button is-link" @click="handleSubmit">{{ $t('auth.forms.send_password_reset_link') }}</button>
</div>
<div class="control">
<router-link :to="{ name: 'login' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
</div>
</div>
</form>
<br />
<span class="tag is-danger" v-if="errorMessage">
{{ errorMessage }}
</span>
</div>
</div>
<div class="columns is-mobile is-centered" v-if="response">
@ -37,13 +41,16 @@
return {
email : '',
validationErrors: {},
response: ''
response: '',
errorMessage: ''
}
},
methods : {
handleSubmit(e){
e.preventDefault()
this.validationErrors = {}
axios.post('/api/password/email', {
email: this.email
})
@ -51,11 +58,11 @@
this.response = response.data.status
})
.catch(error => {
console.log(error.response)
if( error.response.data.errors ) {
this.validationErrors = error.response.data.errors
} else if( error.response.data ) {
this.response = error.response.data.email
}
else if( error.response.data.requestFailed ) {
this.errorMessage = error.response.data.requestFailed
}
else {
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });