Finalize email/password changing in UI
This commit is contained in:
parent
81da55d46b
commit
0cc895f2d5
10 changed files with 158 additions and 23 deletions
|
@ -1,20 +1,34 @@
|
|||
<template>
|
||||
<div>
|
||||
<form action="" method="post">
|
||||
<form method="post" v-on:submit.prevent="submitForm">
|
||||
<div class="content-box">
|
||||
<h2 class="mb-6 text-grey-darkest font-medium">Change your password</h2>
|
||||
<div class="mt-6">
|
||||
<label for="grid-password-current" class="input-label">Current password</label>
|
||||
<input id="grid-password-current" name="password" type="password" class="input" required>
|
||||
<input id="grid-password-current" name="current_password" type="password" class="input" required
|
||||
ref="current"
|
||||
v-model="current"
|
||||
>
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<label for="grid-password-new" class="input-label">New password</label>
|
||||
<input id="grid-password-new" name="password" type="password" class="input" required>
|
||||
<p class="input-help">Your new password should be at least 8 characters in length, contain one number, and be mixed case.</p>
|
||||
<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>
|
||||
<p class="input-help">Your new password should be at least 8 characters in length.</p>
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<label for="grid-password-new-confirm" class="input-label">Confirm new password</label>
|
||||
<input id="grid-password-new-confirm" name="password_confirmation" type="password" class="input" required>
|
||||
<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>
|
||||
</div>
|
||||
<div class="mt-6 text-right">
|
||||
<button class="btn btn-blue btn-sm text-right" type="submit">Save</button>
|
||||
|
@ -25,7 +39,53 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import isObject from 'lodash/isObject';
|
||||
|
||||
export default {
|
||||
name: 'change-password'
|
||||
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 = '';
|
||||
|
||||
this.success('Your password has been updated.');
|
||||
})
|
||||
.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();
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue