Display welcome message and Logout link if the user is already logged in
This commit is contained in:
@ -33,17 +33,15 @@ exports.postSignup = function(req, res) {
|
|||||||
password: req.body.password
|
password: req.body.password
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: add User.schema.path validation
|
|
||||||
user.save(function(err) {
|
user.save(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
|
||||||
if (err.code === 11000) {
|
if (err.code === 11000) {
|
||||||
return res.send('Duplicate user detected');
|
return res.send('Duplicate user detected');
|
||||||
} else if (err.name === 'ValidationError') {
|
} else if (err.name === 'ValidationError') {
|
||||||
return res.send(err.errors);
|
return res.send(err.errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.login(user, function(err) {
|
req.logIn(user, function(err) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
res.redirect('/');
|
res.redirect('/');
|
||||||
});
|
});
|
||||||
|
@ -28,10 +28,16 @@ html
|
|||||||
li(class=title=='Contact'?'active':undefined)
|
li(class=title=='Contact'?'active':undefined)
|
||||||
a(href='#contact') Contact
|
a(href='#contact') Contact
|
||||||
ul.nav.navbar-nav.navbar-right
|
ul.nav.navbar-nav.navbar-right
|
||||||
|
if !user
|
||||||
li(class=title=='Login'?'active':undefined)
|
li(class=title=='Login'?'active':undefined)
|
||||||
a(href='/login') Login
|
a(href='/login') Login
|
||||||
li(class=title=='Create Account'?'active':undefined)
|
li(class=title=='Create Account'?'active':undefined)
|
||||||
a(href='/signup') Create Account
|
a(href='/signup') Create Account
|
||||||
|
else
|
||||||
|
li.navbar-text
|
||||||
|
| Welcome, #{user.firstName} #{user.lastName}
|
||||||
|
li
|
||||||
|
a(href='/logout') Logout
|
||||||
.container
|
.container
|
||||||
block content
|
block content
|
||||||
script(src='/js/lib/jquery.js')
|
script(src='/js/lib/jquery.js')
|
Reference in New Issue
Block a user