fix redirects

v1.18.x
barisusakli 10 years ago
parent 25a2e9b812
commit 724df69561

@ -49,7 +49,7 @@ helpers.redirect = function(res, url) {
if (res.locals.isAPI) {
res.status(302).json(url);
} else {
res.redirect(url);
res.redirect(nconf.get('relative_path') + url);
}
};

@ -60,14 +60,14 @@ middleware.redirectToAccountIfLoggedIn = function(req, res, next) {
if (err) {
return next(err);
}
helpers.redirect(res, '/user/' + userslug);
controllers.helpers.redirect(res, '/user/' + userslug);
});
};
middleware.redirectToLoginIfGuest = function(req, res, next) {
if (!req.user || parseInt(req.user.uid, 10) === 0) {
req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, '');
return res.redirect(nconf.get('relative_path') + '/login');
return controllers.helpers.redirect(res, '/login');
} else {
next();
}
@ -80,7 +80,7 @@ middleware.addSlug = function(req, res, next) {
return next(err);
}
helpers.redirect(res, name + encodeURI(slug));
controllers.helpers.redirect(res, name + encodeURI(slug));
});
}

Loading…
Cancel
Save