mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Merge pull request #5278 from ErisDS/password-imrpv
Password protect redirect optimisation
This commit is contained in:
commit
f2228ab0a4
1 changed files with 5 additions and 2 deletions
|
@ -389,13 +389,16 @@ middleware = {
|
||||||
|
|
||||||
authenticatePrivateSession: function (req, res, next) {
|
authenticatePrivateSession: function (req, res, next) {
|
||||||
var hash = req.session.token || '',
|
var hash = req.session.token || '',
|
||||||
salt = req.session.salt || '';
|
salt = req.session.salt || '',
|
||||||
|
url;
|
||||||
|
|
||||||
return verifySessionHash(salt, hash).then(function (isVerified) {
|
return verifySessionHash(salt, hash).then(function (isVerified) {
|
||||||
if (isVerified) {
|
if (isVerified) {
|
||||||
return next();
|
return next();
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue