2020-01-23 23:02:54 +01:00
|
|
|
<template>
|
2020-09-25 23:36:11 +02:00
|
|
|
<form-wrapper>
|
2020-01-28 15:33:33 +01:00
|
|
|
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
2020-02-13 12:55:00 +01:00
|
|
|
<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')" />
|
2020-02-28 15:21:12 +01:00
|
|
|
<form-field :form="form" fieldName="currentPassword" inputType="password" :label="$t('auth.forms.current_password.label')" :help="$t('auth.forms.current_password.help')" :hasOffset="true" />
|
2020-02-13 12:55:00 +01:00
|
|
|
<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({
|
2020-02-12 17:04:50 +01:00
|
|
|
currentPassword : '',
|
2020-01-23 23:02:54 +01:00
|
|
|
password : '',
|
2020-02-12 17:04:50 +01:00
|
|
|
password_confirmation : '',
|
2020-01-23 23:02:54 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods : {
|
|
|
|
handleSubmit(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
|
2020-03-09 20:24:25 +01:00
|
|
|
this.form.patch('/api/settings/password', {returnError: true})
|
2020-01-23 23:02:54 +01:00
|
|
|
.then(response => {
|
|
|
|
|
2020-09-25 23:36:11 +02:00
|
|
|
this.$notify({ type: 'is-success', text: response.data.message })
|
2020-01-23 23:02:54 +01:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
if( error.response.status === 400 ) {
|
2020-09-25 23:36:11 +02:00
|
|
|
|
|
|
|
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-09-25 23:36:11 +02:00
|
|
|
|
2020-01-23 23:02:54 +01:00
|
|
|
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|