0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Password protect redirect optimisation

no issue

- Don't include r=%2F in the URL - we'll assume this is the default
- This is just a bit prettier
This commit is contained in:
Hannah Wolfe 2015-05-16 20:48:54 +01:00
parent eecfe7241e
commit 4de1c29538

View file

@ -389,13 +389,16 @@ middleware = {
authenticatePrivateSession: function (req, res, next) {
var hash = req.session.token || '',
salt = req.session.salt || '';
salt = req.session.salt || '',
url;
return verifySessionHash(salt, hash).then(function (isVerified) {
if (isVerified) {
return next();
} else {
return res.redirect(config.urlFor({relativeUrl: '/private/'}) + '?r=' + encodeURIComponent(req.url));
url = config.urlFor({relativeUrl: '/private/'});
url += req.url === '/' ? '' : '?r=' + encodeURIComponent(req.url);
return res.redirect(url);
}
});
},