2018-06-16 23:25:26 +00:00
|
|
|
<template>
|
2018-07-15 05:03:19 +00:00
|
|
|
<div id="change-password-container" :class>
|
2018-06-17 23:53:24 +00:00
|
|
|
<form method="post" v-on:submit.prevent="submitForm">
|
2018-06-16 23:43:52 +00:00
|
|
|
<div class="content-box">
|
2018-06-21 06:05:35 +00:00
|
|
|
<h2 class="mb-6 text-grey-darkest font-medium">{{ $t('dashboard.account.password.title') }}</h2>
|
2018-06-16 23:25:26 +00:00
|
|
|
<div class="mt-6">
|
2018-06-21 06:05:35 +00:00
|
|
|
<label for="grid-password-current" class="input-label">{{ $t('strings.password') }}</label>
|
2018-06-17 23:53:24 +00:00
|
|
|
<input id="grid-password-current" name="current_password" type="password" class="input" required
|
|
|
|
ref="current"
|
|
|
|
v-model="current"
|
|
|
|
>
|
2018-06-16 23:25:26 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-6">
|
2018-06-21 06:05:35 +00:00
|
|
|
<label for="grid-password-new" class="input-label">{{ $t('strings.new_password') }}</label>
|
2018-06-17 23:53:24 +00:00
|
|
|
<input id="grid-password-new" name="password" type="password" class="input" required
|
|
|
|
:class="{ error: errors.has('password') }"
|
|
|
|
v-model="newPassword"
|
|
|
|
v-validate="'min:8'"
|
|
|
|
>
|
|
|
|
<p class="input-help error" v-show="errors.has('password')">{{ errors.first('password') }}</p>
|
2018-06-21 06:05:35 +00:00
|
|
|
<p class="input-help">{{ $t('dashboard.account.password.requirements') }}</p>
|
2018-06-16 23:25:26 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-6">
|
2018-06-21 06:05:35 +00:00
|
|
|
<label for="grid-password-new-confirm" class="input-label">{{ $t('strings.confirm_password') }}</label>
|
2018-06-17 23:53:24 +00:00
|
|
|
<input id="grid-password-new-confirm" name="password_confirmation" type="password" class="input" required
|
|
|
|
:class="{ error: errors.has('password_confirmation') }"
|
|
|
|
v-model="confirmNew"
|
|
|
|
v-validate="{is: newPassword}"
|
|
|
|
data-vv-as="password"
|
|
|
|
>
|
|
|
|
<p class="input-help error" v-show="errors.has('password_confirmation')">{{ errors.first('password_confirmation') }}</p>
|
2018-06-16 23:25:26 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-6 text-right">
|
2018-06-21 06:05:35 +00:00
|
|
|
<button class="btn btn-blue btn-sm text-right" type="submit">{{ $t('strings.save') }}</button>
|
2018-06-16 23:25:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2018-12-30 03:24:52 +00:00
|
|
|
<script>
|
2018-06-17 23:53:24 +00:00
|
|
|
import isObject from 'lodash/isObject';
|
|
|
|
|
2018-06-16 23:25:26 +00:00
|
|
|
export default {
|
2018-06-17 23:53:24 +00:00
|
|
|
name: 'change-password',
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
current: '',
|
|
|
|
newPassword: '',
|
|
|
|
confirmNew: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
submitForm: function () {
|
|
|
|
window.axios.put(this.route('api.client.account.update-password'), {
|
|
|
|
current_password: this.$data.current,
|
|
|
|
password: this.$data.newPassword,
|
|
|
|
password_confirmation: this.$data.confirmNew,
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.clearFlashes();
|
|
|
|
this.$validator.pause();
|
|
|
|
this.$data.current = '';
|
|
|
|
this.$refs.current.focus();
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.$data.newPassword = '';
|
|
|
|
this.$data.confirmNew = '';
|
|
|
|
|
2018-06-21 06:05:35 +00:00
|
|
|
this.success(this.$t('dashboard.account.password.updated'));
|
2018-06-17 23:53:24 +00:00
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
if (!err.response) {
|
|
|
|
return console.error(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
const response = err.response;
|
|
|
|
if (response.data && isObject(response.data.errors)) {
|
|
|
|
response.data.errors.forEach(error => {
|
|
|
|
this.error(error.detail);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.$validator.resume();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2018-06-16 23:25:26 +00:00
|
|
|
};
|
|
|
|
</script>
|