|
@@ -1,41 +1,53 @@
|
|
<template>
|
|
<template>
|
|
- <main-header></main-header>
|
|
|
|
- <div class="container">
|
|
|
|
- <!--Implement Validation-->
|
|
|
|
- <label class="label">Username</label>
|
|
|
|
- <p class="control has-icon has-icon-right">
|
|
|
|
- <input class="input is-success" type="text" placeholder="Change username" :value="user.username" v-model="user.username">
|
|
|
|
- <!--Remove validation if it's their own without changing-->
|
|
|
|
- <i class="fa fa-check"></i>
|
|
|
|
- <span class="help is-success">This username is available</span>
|
|
|
|
- </p>
|
|
|
|
- <label class="label">Email</label>
|
|
|
|
- <p class="control has-icon has-icon-right">
|
|
|
|
- <input class="input is-danger" type="text" placeholder="Change email address" :value="user.email" v-model="user.email">
|
|
|
|
- <!--Remove validation if it's their own without changing-->
|
|
|
|
- <i class="fa fa-warning"></i>
|
|
|
|
- <span class="help is-danger">This email is invalid</span>
|
|
|
|
- </p>
|
|
|
|
- <label class="label">Change Password</label>
|
|
|
|
- <div class="control is-grouped">
|
|
|
|
- <p class="control is-expanded has-icon has-icon-right">
|
|
|
|
- <input class="input is-danger" type="text" placeholder="Enter current password" v-model="currentPassword">
|
|
|
|
- <!-- Check if correct -->
|
|
|
|
- <i class="fa fa-warning"></i>
|
|
|
|
- <span class="help is-danger">This password is invalid</span>
|
|
|
|
- </p>
|
|
|
|
- <p class="control is-expanded has-icon has-icon-right">
|
|
|
|
- <input class="input is-danger" type="text" placeholder="Enter new password" v-model="user.password">
|
|
|
|
- <!--Check if longer than x chars, has x, x and x. Kris likes x too ;)-->
|
|
|
|
- <i class="fa fa-warning"></i>
|
|
|
|
- <span class="help is-danger">This password is invalid</span>
|
|
|
|
- </p>
|
|
|
|
|
|
+ <div v-if="isLoggedIn">
|
|
|
|
+ <main-header></main-header>
|
|
|
|
+ <div class="container">
|
|
|
|
+ <!--Implement Validation-->
|
|
|
|
+ <label class="label">Username</label>
|
|
|
|
+ <div class="control is-grouped">
|
|
|
|
+ <p class="control is-expanded has-icon has-icon-right">
|
|
|
|
+ <input class="input is-success" type="text" placeholder="Change username" v-model="user.username">
|
|
|
|
+ <!--Remove validation if it's their own without changing-->
|
|
|
|
+ <i class="fa fa-check"></i>
|
|
|
|
+ <span class="help is-success">This username is available</span>
|
|
|
|
+ </p>
|
|
|
|
+ <p class="control">
|
|
|
|
+ <button class="button is-success" @click="changeUsername()">Save Changes</button>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <label class="label">Email</label>
|
|
|
|
+ <div class="control is-grouped">
|
|
|
|
+ <p class="control is-expanded has-icon has-icon-right">
|
|
|
|
+ <input class="input is-danger" type="text" placeholder="Change email address" v-model="user.email.address">
|
|
|
|
+ <!--Remove validation if it's their own without changing-->
|
|
|
|
+ <i class="fa fa-warning"></i>
|
|
|
|
+ <span class="help is-danger">This email is invalid</span>
|
|
|
|
+ </p>
|
|
|
|
+ <p class="control is-expanded">
|
|
|
|
+ <button class="button is-success" @click="changeEmail()">Save Changes</button>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <label class="label">Change Password</label>
|
|
|
|
+ <div class="control is-grouped">
|
|
|
|
+ <p class="control is-expanded has-icon has-icon-right">
|
|
|
|
+ <input class="input is-danger" type="text" placeholder="Enter current password" v-model="currentPassword">
|
|
|
|
+ <!-- Check if correct -->
|
|
|
|
+ <i class="fa fa-warning"></i>
|
|
|
|
+ <span class="help is-danger">This password is invalid</span>
|
|
|
|
+ </p>
|
|
|
|
+ <p class="control is-expanded has-icon has-icon-right">
|
|
|
|
+ <input class="input is-danger" type="text" placeholder="Enter new password" v-model="newPassword">
|
|
|
|
+ <!--Check if longer than x chars, has x, x and x. Kris likes x too ;)-->
|
|
|
|
+ <i class="fa fa-warning"></i>
|
|
|
|
+ <span class="help is-danger">This password is invalid</span>
|
|
|
|
+ </p>
|
|
|
|
+ <p class="control is-expanded">
|
|
|
|
+ <button class="button is-success" @click="changePassword()">Save Changes</button>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- <p class="control">
|
|
|
|
- <button class="button is-success">Save Changes</button>
|
|
|
|
- </p>
|
|
|
|
|
|
+ <main-footer></main-footer>
|
|
</div>
|
|
</div>
|
|
- <main-footer></main-footer>
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
@@ -44,11 +56,15 @@
|
|
import MainHeader from '../MainHeader.vue';
|
|
import MainHeader from '../MainHeader.vue';
|
|
import MainFooter from '../MainFooter.vue';
|
|
import MainFooter from '../MainFooter.vue';
|
|
|
|
|
|
|
|
+ import LoginModal from '../Modals/Login.vue'
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
currentPassword: '',
|
|
currentPassword: '',
|
|
- user: {}
|
|
|
|
|
|
+ newPassword: '',
|
|
|
|
+ user: {},
|
|
|
|
+ isLoggedIn: false,
|
|
}
|
|
}
|
|
},
|
|
},
|
|
ready: function() {
|
|
ready: function() {
|
|
@@ -56,14 +72,11 @@
|
|
let socketInterval = setInterval(() => {
|
|
let socketInterval = setInterval(() => {
|
|
if (!!_this.$parent.socket) {
|
|
if (!!_this.$parent.socket) {
|
|
_this.socket = _this.$parent.socket;
|
|
_this.socket = _this.$parent.socket;
|
|
- // need to refactor to send whoever is currently logged in
|
|
|
|
- _this.socket.emit('users.findByUsername', 'atjonathan', res => {
|
|
|
|
- if (res.status == 'error') console.error(res.message); // Add 404/ Not found Component with link back to home, for now just console.log
|
|
|
|
- else _this.user = res.data;
|
|
|
|
- });
|
|
|
|
_this.socket.emit('users.findBySession', res => {
|
|
_this.socket.emit('users.findBySession', res => {
|
|
- console.log(res, location.href)
|
|
|
|
- /* if (res.data == null) */ console.log(location.href);
|
|
|
|
|
|
+ if (res.status == 'success') { _this.user = res.data; _this.isLoggedIn = true; } else {
|
|
|
|
+ _this.$parent.isLoginActive = true;
|
|
|
|
+ Toast.methods.addToast('Your are currently not signed in', 3000);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
clearInterval(socketInterval);
|
|
clearInterval(socketInterval);
|
|
}
|
|
}
|
|
@@ -71,25 +84,20 @@
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
changePassword: function () {
|
|
changePassword: function () {
|
|
- if (this.currentPassword !== "" && this.user.password !== "") {
|
|
|
|
- // need to refactor to send whoever is currently logged in
|
|
|
|
- socket.emit('users.update', '582a0724023ecc015c0bef42', 'services.password.password', this.user.password, res => {
|
|
|
|
- if (res.status == 'error') Toast.methods.addToast(res.message, 2000);
|
|
|
|
- else Toast.methods.addToast('Successfully changed password', 2000);
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- Toast.methods.addToast('Current password field is incorrect', 2000);
|
|
|
|
- }
|
|
|
|
|
|
+ if (this.currentPassword == "" || this.newPassword == "") return Toast.methods.addToast('Current password field is incorrect', 2000);
|
|
|
|
+
|
|
|
|
+ this.socket.emit('users.update', this.user._id, 'services.password.password', this.user.password, res => {
|
|
|
|
+ if (res.status == 'error') Toast.methods.addToast(res.message, 2000);
|
|
|
|
+ else Toast.methods.addToast('Successfully changed password', 2000);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
changeEmail: function () {
|
|
changeEmail: function () {
|
|
- if (this.user.email !== "") {
|
|
|
|
- socket.emit('users.update', '582a0724023ecc015c0bef42', 'email.address', this.user.email, res => {
|
|
|
|
- if (res.status == 'error') Toast.methods.addToast(res.message, 2000);
|
|
|
|
- else Toast.methods.addToast('Successfully changed email address', 2000);
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- Toast.methods.addToast('Field cannot be empty', 2000);
|
|
|
|
- }
|
|
|
|
|
|
+ if (this.user.email == "") return Toast.methods.addToast('Field cannot be empty', 2000);
|
|
|
|
+
|
|
|
|
+ this.socket.emit('users.update', this.user._id, 'email.address', this.user.email, res => {
|
|
|
|
+ if (res.status == 'error') Toast.methods.addToast(res.message, 2000);
|
|
|
|
+ else Toast.methods.addToast('Successfully changed email address', 2000);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
// Will be added shortly:
|
|
// Will be added shortly:
|
|
// changeAvatar() {
|
|
// changeAvatar() {
|
|
@@ -112,13 +120,14 @@
|
|
// },
|
|
// },
|
|
changeUsername: function () {
|
|
changeUsername: function () {
|
|
if (this.user.username == "") return Toast.methods.addToast('Field cannot be empty', 2000);
|
|
if (this.user.username == "") return Toast.methods.addToast('Field cannot be empty', 2000);
|
|
- socket.emit('users.update', '582a0724023ecc015c0bef42', 'username', this.user.username, res => {
|
|
|
|
|
|
+
|
|
|
|
+ this.socket.emit('users.update', this.user._id, 'username', this.user.username, res => {
|
|
if (res.status == 'error') Toast.methods.addToast(res.message, 2000);
|
|
if (res.status == 'error') Toast.methods.addToast(res.message, 2000);
|
|
else Toast.methods.addToast('Successfully changed username', 2000);
|
|
else Toast.methods.addToast('Successfully changed username', 2000);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- components: { MainHeader, MainFooter }
|
|
|
|
|
|
+ components: { MainHeader, MainFooter, LoginModal }
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|