mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 14:33:29 +00:00
Merge pull request #18011 from overleaf/dp-make-_getRedirectFromSession-public
Make _getRedirectFromSession a public method GitOrigin-RevId: 6538e4ec25e607d32beb944370d151d4f1a3709c
This commit is contained in:
parent
905c9b2c28
commit
ce00af7838
4 changed files with 13 additions and 13 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue