2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2019-08-25 14:29:28 +00:00
|
|
|
<form
|
|
|
|
class="login-box medium-4 column align-self-middle"
|
|
|
|
@submit.prevent="submit()"
|
|
|
|
>
|
|
|
|
<h4>{{ $t('RESET_PASSWORD.TITLE') }}</h4>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="column log-in-form">
|
2019-08-25 14:29:28 +00:00
|
|
|
<label :class="{ error: $v.credentials.email.$error }">
|
|
|
|
{{ $t('RESET_PASSWORD.EMAIL.LABEL') }}
|
|
|
|
<input
|
|
|
|
v-model.trim="credentials.email"
|
|
|
|
type="text"
|
|
|
|
:placeholder="$t('RESET_PASSWORD.EMAIL.PLACEHOLDER')"
|
|
|
|
@input="$v.credentials.email.$touch"
|
|
|
|
/>
|
|
|
|
<span v-if="$v.credentials.email.$error" class="message">
|
|
|
|
{{ $t('RESET_PASSWORD.EMAIL.ERROR') }}
|
2019-08-14 09:48:44 +00:00
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
<woot-submit-button
|
|
|
|
:disabled="$v.credentials.email.$invalid || resetPassword.showLoading"
|
|
|
|
:button-text="$t('RESET_PASSWORD.SUBMIT')"
|
|
|
|
:loading="resetPassword.showLoading"
|
|
|
|
button-class="expanded"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { required, minLength, email } from 'vuelidate/lib/validators';
|
|
|
|
import Auth from '../../api/auth';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// We need to initialize the component with any
|
|
|
|
// properties that will be used in it
|
|
|
|
credentials: {
|
|
|
|
email: '',
|
|
|
|
},
|
|
|
|
resetPassword: {
|
|
|
|
message: '',
|
|
|
|
showLoading: false,
|
|
|
|
},
|
|
|
|
error: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
validations: {
|
|
|
|
credentials: {
|
|
|
|
email: {
|
|
|
|
required,
|
|
|
|
email,
|
|
|
|
minLength: minLength(4),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
showAlert(message) {
|
|
|
|
// Reset loading, current selected agent
|
|
|
|
this.resetPassword.showLoading = false;
|
|
|
|
bus.$emit('newToastMessage', message);
|
|
|
|
},
|
|
|
|
submit() {
|
|
|
|
this.resetPassword.showLoading = true;
|
|
|
|
Auth.resetPassword(this.credentials)
|
2019-08-25 14:29:28 +00:00
|
|
|
.then(res => {
|
|
|
|
let successMessage = this.$t('RESET_PASSWORD.API.SUCCESS_MESSAGE');
|
2019-08-14 09:48:44 +00:00
|
|
|
if (res.data && res.data.message) {
|
2019-08-25 14:29:28 +00:00
|
|
|
successMessage = res.data.message;
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
2019-08-25 14:29:28 +00:00
|
|
|
this.showAlert(successMessage);
|
2019-08-14 09:48:44 +00:00
|
|
|
})
|
2021-04-20 07:54:33 +00:00
|
|
|
.catch(error => {
|
|
|
|
let errorMessage = this.$t('RESET_PASSWORD.API.ERROR_MESSAGE');
|
|
|
|
if (error?.response?.data?.message) {
|
|
|
|
errorMessage = error.response.data.message;
|
|
|
|
}
|
|
|
|
this.showAlert(errorMessage);
|
2019-08-14 09:48:44 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|