2020-10-15 11:29:56 -07:00
|
|
|
<template>
|
|
|
|
<section>
|
2020-10-15 15:41:41 -07:00
|
|
|
<div class="card mb-3">
|
|
|
|
<div class="card-body d-flex flex-column flex-md-row">
|
2020-10-16 01:08:48 -07:00
|
|
|
<div class="mx-2 text-center">
|
|
|
|
<p class="mb-0">
|
2020-10-15 15:41:41 -07:00
|
|
|
<Avatar :user="$user()"/>
|
|
|
|
</p>
|
2020-10-16 01:08:48 -07:00
|
|
|
<p>
|
2020-10-15 15:41:41 -07:00
|
|
|
<a href="https://gravatar.com" target="_blank" rel="noopener" class="small">
|
2020-10-16 01:08:48 -07:00
|
|
|
<Icon v="external-link"/>
|
2020-10-15 15:41:41 -07:00
|
|
|
<T>user.avatar.change</T>
|
|
|
|
</a>
|
|
|
|
</p>
|
2020-10-16 01:08:48 -07:00
|
|
|
<p v-if="$admin()">
|
|
|
|
<span class="badge badge-primary"><T>user.account.admin</T></span>
|
|
|
|
</p>
|
2020-10-15 15:41:41 -07:00
|
|
|
</div>
|
|
|
|
<div class="mx-2 flex-grow-1">
|
|
|
|
<Alert type="danger" :message="error"/>
|
|
|
|
|
|
|
|
<form @submit.prevent="changeUsername">
|
|
|
|
<h3 class="h6"><T>user.account.changeUsername.header</T></h3>
|
|
|
|
<div class="input-group mb-3">
|
|
|
|
<input type="text" class="form-control" v-model="username"
|
|
|
|
required minlength="4" maxlength="16"/>
|
|
|
|
<div class="input-group-append">
|
|
|
|
<button class="btn btn-outline-primary">
|
|
|
|
<T>user.account.changeUsername.action</T>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<h3 class="h6"><T>user.account.changeEmail.header</T></h3>
|
|
|
|
<p>{{ email }}</p>
|
|
|
|
</div>
|
2020-10-15 11:29:56 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-10-15 15:41:41 -07:00
|
|
|
<p>
|
|
|
|
<button class="btn btn-outline-secondary btn-sm" @click="logout">
|
|
|
|
<Icon v="sign-out"/>
|
|
|
|
<T>user.logout</T>
|
|
|
|
</button>
|
2020-10-15 11:29:56 -07:00
|
|
|
</p>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
username: this.$user().username,
|
|
|
|
email: this.$user().email,
|
|
|
|
|
|
|
|
error: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async changeUsername() {
|
|
|
|
await this.post(`/user/change-username`, {
|
|
|
|
username: this.username
|
2020-10-15 11:55:24 -07:00
|
|
|
}, { headers: this.$auth() });
|
2020-10-15 11:29:56 -07:00
|
|
|
},
|
|
|
|
async post(url, data, options = {}) {
|
|
|
|
this.error = '';
|
|
|
|
|
|
|
|
const response = await this.$axios.$post(url, data, options);
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
this.error = response.error;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$store.commit('setToken', response.token);
|
|
|
|
this.$cookies.set('token', this.$store.state.token);
|
|
|
|
},
|
|
|
|
logout() {
|
|
|
|
this.$store.commit('setToken', null);
|
|
|
|
this.$cookies.removeAll();
|
2020-10-15 15:41:41 -07:00
|
|
|
},
|
2020-10-15 11:29:56 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|