front/registration: add welcome message
This commit is contained in:
parent
3b996d01e5
commit
1ad71585c4
2 changed files with 8 additions and 3 deletions
|
@ -78,6 +78,7 @@ class Api {
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
this.user = null;
|
||||||
this.userName = null;
|
this.userName = null;
|
||||||
this.userPassword = null;
|
this.userPassword = null;
|
||||||
this.authenticated.fire();
|
this.authenticated.fire();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const cookies = require('js-cookie');
|
||||||
const page = require('page');
|
const page = require('page');
|
||||||
const api = require('../api.js');
|
const api = require('../api.js');
|
||||||
const topNavController = require('../controllers/top_nav_controller.js');
|
const topNavController = require('../controllers/top_nav_controller.js');
|
||||||
|
@ -16,7 +17,9 @@ class UsersController {
|
||||||
|
|
||||||
createUserRoute() {
|
createUserRoute() {
|
||||||
topNavController.activate('register');
|
topNavController.activate('register');
|
||||||
this.registrationView.render({register: this._register});
|
this.registrationView.render({register: (...args) => {
|
||||||
|
return this._register(...args);
|
||||||
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
_register(name, password, email) {
|
_register(name, password, email) {
|
||||||
|
@ -29,8 +32,10 @@ class UsersController {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
api.post('/users/', data).then(() => {
|
api.post('/users/', data).then(() => {
|
||||||
api.login(name, password).then(() => {
|
api.login(name, password).then(() => {
|
||||||
|
cookies.set('auth', {'user': name, 'password': password});
|
||||||
resolve();
|
resolve();
|
||||||
page('/');
|
page('/');
|
||||||
|
this.registrationView.notifySuccess('Welcome aboard!');
|
||||||
}).catch(response => {
|
}).catch(response => {
|
||||||
reject(response.description);
|
reject(response.description);
|
||||||
});
|
});
|
||||||
|
@ -41,8 +46,7 @@ class UsersController {
|
||||||
}
|
}
|
||||||
|
|
||||||
showUserRoute(user) {
|
showUserRoute(user) {
|
||||||
if (api.isLoggedIn() &&
|
if (api.isLoggedIn() && user == api.userName) {
|
||||||
user == api.getCurrentUser().name) {
|
|
||||||
topNavController.activate('account');
|
topNavController.activate('account');
|
||||||
} else {
|
} else {
|
||||||
topNavController.activate('users');
|
topNavController.activate('users');
|
||||||
|
|
Loading…
Reference in a new issue