2FAuth/resources/js/views/settings/Password.vue

49 lines
1.8 KiB
Vue
Raw Normal View History

2020-01-23 23:02:54 +01:00
<template>
<form-wrapper>
2020-01-28 15:33:33 +01:00
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
<form-field :form="form" fieldName="password" inputType="password" :label="$t('auth.forms.new_password')" />
<form-field :form="form" fieldName="password_confirmation" inputType="password" :label="$t('auth.forms.confirm_new_password')" />
<form-field :form="form" fieldName="currentPassword" inputType="password" :label="$t('auth.forms.current_password.label')" :help="$t('auth.forms.current_password.help')" :hasOffset="true" />
<form-buttons :isBusy="form.isBusy" :caption="$t('auth.forms.change_password')" />
2020-01-28 15:33:33 +01:00
</form>
</form-wrapper>
2020-01-23 23:02:54 +01:00
</template>
<script>
import Form from './../../components/Form'
export default {
data(){
return {
form: new Form({
currentPassword : '',
2020-01-23 23:02:54 +01:00
password : '',
password_confirmation : '',
2020-01-23 23:02:54 +01:00
})
}
},
methods : {
handleSubmit(e) {
e.preventDefault()
this.form.patch('/api/settings/password', {returnError: true})
2020-01-23 23:02:54 +01:00
.then(response => {
this.$notify({ type: 'is-success', text: response.data.message })
2020-01-23 23:02:54 +01:00
})
.catch(error => {
if( error.response.status === 400 ) {
this.$notify({ type: 'is-danger', text: error.response.data.message })
2020-01-23 23:02:54 +01:00
}
else if( error.response.status !== 422 ) {
2020-01-23 23:02:54 +01:00
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
});
}
},
}
</script>