Merge pull request #406 from QuincyLarson/auth

potentially fix the too many redirects issue
This commit is contained in:
Quincy Larson
2015-05-01 21:32:57 -07:00
3 changed files with 13 additions and 15 deletions

View File

@ -3,7 +3,13 @@
* Home page.
*/
exports.index = function(req, res) {
exports.index = function(req, res, next) {
if (req.user && !req.user.profile.picture) {
req.user.profile.picture = 'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png';
req.user.save(function(err) {
if (err) { return next(err); }
});
}
res.render('home', {
title: 'Learn to Code JavaScript and get a Coding Job by Helping Nonprofits'
});

View File

@ -55,7 +55,7 @@ exports.postSignin = function(req, res, next) {
return next(err);
}
req.flash('success', { msg: 'Success! You are logged in.' });
res.redirect(req.session.returnTo || '/');
return res.redirect(req.session.returnTo || '/');
});
})(req, res, next);
};

View File

@ -41,17 +41,9 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
else
a(href='/account') [ #{user.progressTimestamps.length} ]
.hidden-xs.hidden-sm
if user.profile.picture
if (user.profile.username)
a(href='/' + user.profile.username)
img.profile-picture.float-right(src='#{user.profile.picture}')
else
a(href='/account')
img.profile-picture.float-right(src='#{user.profile.picture}')
if (user.profile.username)
a(href='/' + user.profile.username)
img.profile-picture.float-right(src='#{user.profile.picture}')
else
if (user.profile.username)
a(href='/' + user.profile.username)
img.profile-picture.float-right(src='#{user.gravatar(60)}')
else
a(href='/account')
img.profile-picture.float-right(src='#{user.gravatar(60)}')
a(href='/account')
img.profile-picture.float-right(src='#{user.profile.picture}')