Skip to content

Commit

Permalink
🐛 Fixed redirect issue with private sites (#9960)
Browse files Browse the repository at this point in the history
closes #9959

This issue existed because the logic assumed that if there were no
query parameters then there would be no `query` object. However this is
not the case. What we really wanted to check was for the existence of an
"r" query param - the code has been refactor to explicitly do this now.
  • Loading branch information
kirrg001 committed Nov 7, 2018
1 parent e70fb1e commit 2208af7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/server/apps/private-blogging/lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function verifySessionHash(salt, hash) {
}

function getRedirectUrl(query) {
var redirect = decodeURIComponent(query ? query.r : '/');
var redirect = decodeURIComponent(query.r || '/');
try {
return url.parse(redirect, config.urlFor('home', true)).pathname;
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion core/server/apps/private-blogging/tests/middleware_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ describe('Private Blogging', function () {
var req, res, next;

beforeEach(function () {
req = {};
req = {
query: {}
};
res = {};
apiSettingsStub = sandbox.stub(api.settings, 'read');
next = sinon.spy();
Expand Down

0 comments on commit 2208af7

Please sign in to comment.