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

80 lines
2.9 KiB
Vue
Raw Normal View History

2020-01-14 23:50:07 +01:00
<template>
2020-01-28 15:33:33 +01:00
<form-wrapper :title="$t('auth.forms.new_password')" :fail="fail" :success="success">
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
<div class="field">
<label class="label">{{ $t('auth.forms.email') }}</label>
<div class="control">
<input id="email" type="email" class="input" v-model="form.email" disabled readonly />
</div>
<field-error :form="form" field="email" />
2020-01-14 23:50:07 +01:00
</div>
2020-01-28 15:33:33 +01:00
<div class="field">
<label class="label">{{ $t('auth.forms.new_password') }}</label>
<div class="control">
<input id="password" type="password" class="input" v-model="form.password" />
</div>
<field-error :form="form" field="password" />
</div>
<div class="field">
<label class="label">{{ $t('auth.forms.confirm_password') }}</label>
<div class="control">
<input id="password_confirmation" type="password" class="input" v-model="form.password_confirmation" />
</div>
<field-error :form="form" field="password_confirmation" />
</div>
<div class="field is-grouped">
<div class="control">
<v-button :isLoading="form.isBusy" >{{ $t('auth.forms.change_password') }}</v-button>
</div>
<div class="control">
<router-link :to="{ name: 'login' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
</div>
</div>
</form>
</form-wrapper>
2020-01-14 23:50:07 +01:00
</template>
<script>
2020-01-20 22:51:57 +01:00
import Form from './../../../components/Form'
2020-01-14 23:50:07 +01:00
export default {
data(){
return {
2020-01-28 15:33:33 +01:00
success: '',
fail: '',
2020-01-20 22:51:57 +01:00
form: new Form({
email : '',
password : '',
password_confirmation : '',
token: ''
})
2020-01-14 23:50:07 +01:00
}
},
created () {
2020-01-20 22:51:57 +01:00
this.form.email = this.$route.query.email
this.form.token = this.$route.params.token
2020-01-14 23:50:07 +01:00
},
methods : {
2020-01-19 22:29:36 +01:00
handleSubmit(e) {
2020-01-14 23:50:07 +01:00
e.preventDefault()
2020-01-27 21:13:21 +01:00
this.form.post('/api/password/reset', {returnError: true})
2020-01-19 22:29:36 +01:00
.then(response => {
2020-01-16 22:21:05 +01:00
this.success = response.data.status
2020-01-19 22:29:36 +01:00
})
.catch(error => {
2020-01-20 22:51:57 +01:00
if( error.response.data.resetFailed ) {
2020-01-28 15:33:33 +01:00
this.fail = error.response.data.resetFailed
}
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 23:50:07 +01:00
}
2020-01-19 22:29:36 +01:00
});
2020-01-14 23:50:07 +01:00
}
},
}
</script>