2020-01-14 17:06:59 +01:00
|
|
|
<template>
|
|
|
|
<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">
|
2020-01-15 11:48:22 +01:00
|
|
|
<h1 class="title">{{ $t('auth.forms.reset_password') }}</h1>
|
2020-01-14 23:50:07 +01:00
|
|
|
<form method="POST" action="/password/email">
|
2020-01-14 17:06:59 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">{{ $t('auth.forms.email') }}</label>
|
|
|
|
<div class="control">
|
|
|
|
<input id="email" type="email" class="input" v-model="email" required autofocus />
|
|
|
|
</div>
|
|
|
|
<p class="help is-danger" v-if="validationErrors.email">{{ validationErrors.email.toString() }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2020-01-15 11:48:22 +01:00
|
|
|
<button type="submit" class="button is-link" @click="handleSubmit">{{ $t('auth.forms.send_password_reset_link') }}</button>
|
2020-01-14 17:06:59 +01:00
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<router-link :to="{ name: 'login' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2020-01-15 11:48:22 +01:00
|
|
|
<br />
|
|
|
|
<span class="tag is-danger" v-if="errorMessage">
|
|
|
|
{{ errorMessage }}
|
|
|
|
</span>
|
2020-01-14 17:06:59 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-14 23:50:07 +01:00
|
|
|
<div class="columns is-mobile is-centered" v-if="response">
|
|
|
|
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
|
|
|
{{ response }}
|
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-14 17:06:59 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data(){
|
|
|
|
return {
|
|
|
|
email : '',
|
2020-01-14 23:50:07 +01:00
|
|
|
validationErrors: {},
|
2020-01-15 11:48:22 +01:00
|
|
|
response: '',
|
|
|
|
errorMessage: ''
|
2020-01-14 17:06:59 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods : {
|
2020-01-19 22:29:36 +01:00
|
|
|
handleSubmit(e){
|
2020-01-14 17:06:59 +01:00
|
|
|
e.preventDefault()
|
|
|
|
|
2020-01-15 11:48:22 +01:00
|
|
|
this.validationErrors = {}
|
|
|
|
|
2020-01-19 22:29:36 +01:00
|
|
|
axios.post('/api/password/email', {
|
|
|
|
email: this.email
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
|
|
|
|
this.response = response.data.status
|
|
|
|
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2020-01-16 22:21:05 +01:00
|
|
|
|
2020-01-19 23:02:20 +01:00
|
|
|
if( error.response.status == 422 ) {
|
2020-01-14 17:06:59 +01:00
|
|
|
this.validationErrors = error.response.data.errors
|
2020-01-15 11:48:22 +01:00
|
|
|
}
|
|
|
|
else if( error.response.data.requestFailed ) {
|
|
|
|
this.errorMessage = error.response.data.requestFailed
|
2020-01-14 17:06:59 +01:00
|
|
|
}
|
|
|
|
else {
|
2020-01-17 00:23:38 +01:00
|
|
|
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
2020-01-14 17:06:59 +01:00
|
|
|
}
|
2020-01-19 22:29:36 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-01-14 17:06:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|