get account should redirect to '/' when no user is logged in
This commit is contained in:
@ -28,6 +28,7 @@ module.exports = function(app) {
|
||||
router.post('/reset/:token', postReset);
|
||||
router.get('/email-signup', getEmailSignup);
|
||||
router.get('/email-signin', getEmailSignin);
|
||||
|
||||
router.get('/account/api', getAccountAngular);
|
||||
router.post('/account/profile', postUpdateProfile);
|
||||
router.post('/account/password', postUpdatePassword);
|
||||
@ -97,6 +98,9 @@ module.exports = function(app) {
|
||||
*/
|
||||
|
||||
function getAccount (req, res) {
|
||||
if (!req.user) {
|
||||
return res.redirect('/');
|
||||
}
|
||||
res.render('account/account', {
|
||||
title: 'Manage your Free Code Camp Account'
|
||||
});
|
||||
@ -108,7 +112,7 @@ module.exports = function(app) {
|
||||
|
||||
function getAccountAngular (req, res) {
|
||||
res.json({
|
||||
user: req.user
|
||||
user: req.user || {}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user