diff --git a/services/web/app/src/Features/Authentication/AuthenticationController.js b/services/web/app/src/Features/Authentication/AuthenticationController.js index 671a801afd..84bc2640d2 100644 --- a/services/web/app/src/Features/Authentication/AuthenticationController.js +++ b/services/web/app/src/Features/Authentication/AuthenticationController.js @@ -177,7 +177,7 @@ const AuthenticationController = { } const redir = - AuthenticationController._getRedirectFromSession(req) || '/project' + AuthenticationController.getRedirectFromSession(req) || '/project' _loginAsyncHandlers(req, user, anonymousAnalyticsId, isNewUser) const userId = user._id @@ -283,7 +283,7 @@ const AuthenticationController = { } else if (user) { if ( isPasswordReused && - AuthenticationController._getRedirectFromSession(req) == null + AuthenticationController.getRedirectFromSession(req) == null ) { AuthenticationController.setRedirectInSession( req, @@ -613,7 +613,7 @@ const AuthenticationController = { if (callback) callback() }, - _getRedirectFromSession(req) { + getRedirectFromSession(req) { let safePath const value = _.get(req, ['session', 'postLoginRedirect']) if (value) { diff --git a/services/web/app/src/Features/User/UserPagesController.js b/services/web/app/src/Features/User/UserPagesController.js index 7d371c2bed..92b5f2dc8e 100644 --- a/services/web/app/src/Features/User/UserPagesController.js +++ b/services/web/app/src/Features/User/UserPagesController.js @@ -236,7 +236,7 @@ const UserPagesController = { // such as being sent from the editor to /login, then set the redirect explicitly if ( req.query.redir != null && - AuthenticationController._getRedirectFromSession(req) == null + AuthenticationController.getRedirectFromSession(req) == null ) { AuthenticationController.setRedirectInSession(req, req.query.redir) } diff --git a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js index 70375db158..896ca24442 100644 --- a/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js +++ b/services/web/test/unit/src/Authentication/AuthenticationControllerTests.js @@ -1108,23 +1108,23 @@ describe('AuthenticationController', function () { }) }) - describe('_getRedirectFromSession', function () { + describe('getRedirectFromSession', function () { it('should get redirect property from session', function () { this.req = { session: { postLoginRedirect: '/a?b=c' } } expect( - this.AuthenticationController._getRedirectFromSession(this.req) + this.AuthenticationController.getRedirectFromSession(this.req) ).to.equal('/a?b=c') }) it('should not allow open redirects', function () { this.req = { session: { postLoginRedirect: 'https://evil.com' } } - expect(this.AuthenticationController._getRedirectFromSession(this.req)).to + expect(this.AuthenticationController.getRedirectFromSession(this.req)).to .be.null }) it('handle null values', function () { this.req = { session: {} } - expect(this.AuthenticationController._getRedirectFromSession(this.req)).to + expect(this.AuthenticationController.getRedirectFromSession(this.req)).to .be.null }) }) @@ -1147,7 +1147,7 @@ describe('AuthenticationController', function () { // - clear redirect // - issue redir, two ways beforeEach(function () { - this.AuthenticationController._getRedirectFromSession = sinon + this.AuthenticationController.getRedirectFromSession = sinon .stub() .returns('/some/page') @@ -1181,10 +1181,10 @@ describe('AuthenticationController', function () { this.next ) expect( - this.AuthenticationController._getRedirectFromSession.callCount + this.AuthenticationController.getRedirectFromSession.callCount ).to.equal(1) expect( - this.AuthenticationController._getRedirectFromSession.calledWith( + this.AuthenticationController.getRedirectFromSession.calledWith( this.req ) ).to.equal(true) diff --git a/services/web/test/unit/src/User/UserPagesControllerTests.js b/services/web/test/unit/src/User/UserPagesControllerTests.js index 76d1aeed5b..e16b41b835 100644 --- a/services/web/test/unit/src/User/UserPagesControllerTests.js +++ b/services/web/test/unit/src/User/UserPagesControllerTests.js @@ -58,7 +58,7 @@ describe('UserPagesController', function () { subscribed: sinon.stub().yields(), } this.AuthenticationController = { - _getRedirectFromSession: sinon.stub(), + getRedirectFromSession: sinon.stub(), setRedirectInSession: sinon.stub(), } this.Features = { @@ -169,7 +169,7 @@ describe('UserPagesController', function () { describe('when an explicit redirect is set via query string', function () { beforeEach(function () { - this.AuthenticationController._getRedirectFromSession = sinon + this.AuthenticationController.getRedirectFromSession = sinon .stub() .returns(null) this.AuthenticationController.setRedirectInSession = sinon.stub()