2FAuth/resources/js/views/auth/password/Request.vue

53 lines
1.7 KiB
Vue
Raw Normal View History

2020-01-14 17:06:59 +01:00
<template>
2020-11-24 22:57:32 +01:00
<form-wrapper :title="$t('auth.forms.reset_password')" :punchline="$t('auth.forms.reset_punchline')">
2020-01-28 15:33:33 +01:00
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
<form-field :form="form" fieldName="email" inputType="email" :label="$t('auth.forms.email')" autofocus />
<form-buttons :isBusy="form.isBusy" :caption="$t('auth.forms.send_password_reset_link')" :showCancelButton="true" cancelLandingView="login" />
2020-01-28 15:33:33 +01:00
</form>
</form-wrapper>
2020-01-14 17:06:59 +01:00
</template>
<script>
2020-01-20 22:51:57 +01:00
import Form from './../../../components/Form'
2020-01-14 17:06:59 +01:00
export default {
data(){
return {
2020-01-20 22:51:57 +01:00
form: new Form({
email: '',
})
2020-01-14 17:06:59 +01:00
}
},
methods : {
2020-01-20 22:51:57 +01:00
handleSubmit(e) {
2020-01-14 17:06:59 +01:00
e.preventDefault()
this.form.post('/api/user/password/lost', {returnError: true})
2020-01-19 22:29:36 +01:00
.then(response => {
this.$notify({ type: 'is-success', text: response.data.message, duration:-1 })
2020-01-19 22:29:36 +01:00
})
.catch(error => {
2020-01-20 22:51:57 +01:00
if( error.response.data.requestFailed ) {
this.$notify({ type: 'is-danger', text: error.response.data.requestFailed, duration:-1 })
2020-01-14 17:06:59 +01:00
}
2020-01-20 22:51:57 +01:00
else if( error.response.status !== 422 ) {
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
}
},
beforeRouteLeave (to, from, next) {
this.$notify({
clean: true
})
next()
2020-01-14 17:06:59 +01:00
}
}
</script>