2018-06-12 05:36:43 +00:00
|
|
|
<template>
|
2018-07-15 05:03:19 +00:00
|
|
|
<div id="update-email-container" :class>
|
2018-06-12 05:36:43 +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.email.title') }}</h2>
|
2018-06-12 05:36:43 +00:00
|
|
|
<div>
|
2018-06-21 06:05:35 +00:00
|
|
|
<label for="grid-email" class="input-label">{{ $t('strings.email_address') }}</label>
|
2018-06-12 05:36:43 +00:00
|
|
|
<input id="grid-email" name="email" type="email" class="input" required
|
2018-06-17 23:53:24 +00:00
|
|
|
:class="{ error: errors.has('email') }"
|
|
|
|
v-validate
|
|
|
|
v-model="email"
|
2018-06-12 05:36:43 +00:00
|
|
|
>
|
2018-06-17 23:53:24 +00:00
|
|
|
<p class="input-help error" v-show="errors.has('email')">{{ errors.first('email') }}</p>
|
2018-06-12 05:36:43 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-6">
|
2018-06-21 06:05:35 +00:00
|
|
|
<label for="grid-password" class="input-label">{{ $t('strings.password') }}</label>
|
2018-06-12 05:36:43 +00:00
|
|
|
<input id="grid-password" name="password" type="password" class="input" required
|
|
|
|
v-model="password"
|
|
|
|
>
|
|
|
|
</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-12 05:36:43 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2018-12-30 01:00:50 +00:00
|
|
|
<script lang="ts">
|
2018-06-17 23:53:24 +00:00
|
|
|
import { isObject, get } from 'lodash';
|
2018-06-12 05:36:43 +00:00
|
|
|
import { mapState, mapActions } from 'vuex';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'update-email',
|
|
|
|
data: function () {
|
|
|
|
return {
|
2018-06-17 23:53:24 +00:00
|
|
|
email: get(this.$store.state, 'auth.user.email', ''),
|
2018-06-12 05:36:43 +00:00
|
|
|
password: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
user: state => state.auth.user,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
/**
|
|
|
|
* Update a user's email address on the Panel.
|
|
|
|
*/
|
|
|
|
submitForm: function () {
|
|
|
|
this.clearFlashes();
|
|
|
|
this.updateEmail({
|
|
|
|
email: this.$data.email,
|
2018-06-16 21:30:20 +00:00
|
|
|
password: this.$data.password
|
2018-06-12 05:36:43 +00:00
|
|
|
})
|
2018-06-17 23:53:24 +00:00
|
|
|
.finally(() => {
|
|
|
|
this.$data.password = '';
|
|
|
|
})
|
2018-06-12 05:36:43 +00:00
|
|
|
.then(() => {
|
2018-06-21 06:05:35 +00:00
|
|
|
this.success(this.$t('dashboard.account.email.updated'));
|
2018-06-12 05:36:43 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
if (!error.response) {
|
2018-06-12 05:56:57 +00:00
|
|
|
this.error(error.message);
|
2018-06-12 05:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const response = error.response;
|
2018-06-16 22:05:36 +00:00
|
|
|
if (response.data && isObject(response.data.errors)) {
|
2018-06-12 05:36:43 +00:00
|
|
|
response.data.errors.forEach(e => {
|
|
|
|
this.error(e.detail);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
...mapActions('auth', [
|
|
|
|
'updateEmail',
|
|
|
|
])
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|