2018-03-31 20:52:11 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2018-04-07 21:17:51 +00:00
|
|
|
<form class="bg-white shadow-lg rounded-lg pt-10 px-8 pb-6 mb-4 animate fadein" method="post"
|
|
|
|
v-on:submit.prevent="submitForm"
|
|
|
|
>
|
2018-03-31 20:52:11 +00:00
|
|
|
<div class="flex flex-wrap -mx-3 mb-6">
|
|
|
|
<div class="input-open">
|
2018-06-02 23:39:49 +00:00
|
|
|
<input class="input" id="grid-email" type="email" aria-labelledby="grid-email-label" required
|
|
|
|
ref="email"
|
2018-04-08 20:18:13 +00:00
|
|
|
v-bind:class="{ 'has-content': email.length > 0 }"
|
2018-04-07 21:17:51 +00:00
|
|
|
v-bind:readonly="showSpinner"
|
2018-03-31 20:52:11 +00:00
|
|
|
v-bind:value="email"
|
|
|
|
v-on:input="updateEmail($event)"
|
|
|
|
/>
|
2018-06-02 23:39:49 +00:00
|
|
|
<label for="grid-email" id="grid-email-label">{{ $t('strings.email') }}</label>
|
2018-04-08 20:18:13 +00:00
|
|
|
<p class="text-grey-darker text-xs">{{ $t('auth.forgot_password.label_help') }}</p>
|
2018-03-31 20:52:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
2018-04-07 21:17:51 +00:00
|
|
|
<button class="btn btn-blue btn-jumbo" type="submit" v-bind:disabled="submitDisabled">
|
|
|
|
<span class="spinner white" v-bind:class="{ hidden: ! showSpinner }"> </span>
|
|
|
|
<span v-bind:class="{ hidden: showSpinner }">
|
2018-04-08 20:18:13 +00:00
|
|
|
{{ $t('auth.forgot_password.button') }}
|
2018-04-07 21:17:51 +00:00
|
|
|
</span>
|
2018-03-31 20:52:11 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="pt-6 text-center">
|
2018-04-08 20:46:32 +00:00
|
|
|
<router-link class="text-xs text-grey tracking-wide no-underline uppercase hover:text-grey-dark"
|
2018-06-02 23:39:49 +00:00
|
|
|
aria-label="Go to login"
|
2018-04-08 20:46:32 +00:00
|
|
|
:to="{ name: 'login' }"
|
|
|
|
>
|
2018-03-31 21:33:10 +00:00
|
|
|
{{ $t('auth.go_to_login') }}
|
2018-03-31 20:52:11 +00:00
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'forgot-password',
|
|
|
|
props: {
|
|
|
|
email: {type: String, required: true},
|
|
|
|
},
|
2018-04-01 22:46:16 +00:00
|
|
|
mounted: function () {
|
|
|
|
this.$refs.email.focus();
|
|
|
|
},
|
2018-03-31 21:44:20 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
|
2018-04-07 21:17:51 +00:00
|
|
|
errors: [],
|
|
|
|
submitDisabled: false,
|
|
|
|
showSpinner: false,
|
2018-03-31 21:44:20 +00:00
|
|
|
};
|
|
|
|
},
|
2018-03-31 20:52:11 +00:00
|
|
|
methods: {
|
|
|
|
updateEmail: function (event) {
|
2018-04-07 21:17:51 +00:00
|
|
|
this.$data.submitDisabled = false;
|
2018-03-31 20:52:11 +00:00
|
|
|
this.$emit('update-email', event.target.value);
|
2018-04-07 21:17:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
submitForm: function () {
|
|
|
|
const self = this;
|
|
|
|
this.$data.submitDisabled = true;
|
|
|
|
this.$data.showSpinner = true;
|
|
|
|
this.$data.errors = [];
|
|
|
|
|
2018-05-26 21:50:38 +00:00
|
|
|
this.clearFlashes();
|
2018-04-08 20:18:13 +00:00
|
|
|
window.axios.post(this.route('auth.forgot-password'), {
|
2018-04-07 21:17:51 +00:00
|
|
|
email: this.$props.email,
|
|
|
|
})
|
|
|
|
.then(function (response) {
|
2018-06-02 23:59:16 +00:00
|
|
|
if (!(response.data instanceof Object)) {
|
|
|
|
throw new Error('An error was encountered while processing this request.');
|
|
|
|
}
|
|
|
|
|
2018-04-07 21:17:51 +00:00
|
|
|
self.$data.submitDisabled = false;
|
|
|
|
self.$data.showSpinner = false;
|
2018-05-26 21:50:38 +00:00
|
|
|
self.success(response.data.status);
|
2018-04-07 21:17:51 +00:00
|
|
|
self.$router.push({name: 'login'});
|
|
|
|
})
|
|
|
|
.catch(function (err) {
|
|
|
|
self.$data.showSpinner = false;
|
|
|
|
if (!err.response) {
|
|
|
|
return console.error(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
const response = err.response;
|
|
|
|
if (response.data && _.isObject(response.data.errors)) {
|
2018-05-26 21:50:38 +00:00
|
|
|
response.data.errors.forEach(function (error) {
|
|
|
|
self.error(error.detail);
|
|
|
|
});
|
2018-04-07 21:17:51 +00:00
|
|
|
}
|
|
|
|
});
|
2018-03-31 20:52:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|