|
@@ -45,24 +45,24 @@
|
|
|
events: {
|
|
|
'register': function () {
|
|
|
let { register: { email, username, password } } = this;
|
|
|
- this.socket.emit('users.register', username, email, password, grecaptcha.getResponse(), (result) => {
|
|
|
- // Need to somehow execute this on Home.vue
|
|
|
- // Toast.methods.addToast(`User ${username} has been registered`, 2000);
|
|
|
+ this.socket.emit('users.register', username, email, password, grecaptcha.getResponse(), result => {
|
|
|
+ Toast.methods.addToast(`User ${username} has been registered`, 2000);
|
|
|
setTimeout(location.reload(), 2500);
|
|
|
});
|
|
|
},
|
|
|
'login': function () {
|
|
|
let { login: { email, password } } = this;
|
|
|
|
|
|
- this.socket.emit('users.login', email, password, (result) => {
|
|
|
+ this.socket.emit('users.login', email, password, result => {
|
|
|
console.log(result);
|
|
|
if (result.status === 'success') {
|
|
|
let date = new Date();
|
|
|
date.setTime(new Date().getTime() + (2*365*24*60*60*1000));
|
|
|
document.cookie = "SID=" + result.sessionId + "; expires="+ date.toGMTString() +"; path=/";
|
|
|
- location.reload();
|
|
|
+ Toast.methods.addToast(`You have been successfully logged in`, 2000);
|
|
|
+ setTimeout(location.reload(), 2500);
|
|
|
} else {
|
|
|
- //TODO Error toast
|
|
|
+ Toast.methods.addToast(result.message, 2000);
|
|
|
}
|
|
|
});
|
|
|
}
|