mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Set redirect when sending user to login
page.
Allows smart redirecting to work when public access is turned off.
This commit is contained in:
parent
0b67265eb6
commit
f5ced03074
2 changed files with 8 additions and 0 deletions
|
@ -148,6 +148,7 @@ module.exports = AuthenticationController =
|
|||
return next()
|
||||
else
|
||||
logger.log url:req.url, "user trying to access endpoint not in global whitelist"
|
||||
AuthenticationController._setRedirectInSession(req)
|
||||
return res.redirect "/login"
|
||||
|
||||
httpAuth: basicAuth (user, pass)->
|
||||
|
|
|
@ -387,6 +387,10 @@ describe "AuthenticationController", ->
|
|||
beforeEach ->
|
||||
@req.headers = {}
|
||||
@AuthenticationController.httpAuth = sinon.stub()
|
||||
@_setRedirect = sinon.spy(@AuthenticationController, '_setRedirectInSession')
|
||||
|
||||
afterEach ->
|
||||
@_setRedirect.restore()
|
||||
|
||||
describe "with white listed url", ->
|
||||
beforeEach ->
|
||||
|
@ -431,6 +435,9 @@ describe "AuthenticationController", ->
|
|||
@req.session = {}
|
||||
@AuthenticationController.requireGlobalLogin @req, @res, @next
|
||||
|
||||
it 'should have called setRedirectInSession', ->
|
||||
@_setRedirect.callCount.should.equal 1
|
||||
|
||||
it "should redirect to the /login page", ->
|
||||
@res.redirectedTo.should.equal "/login"
|
||||
|
||||
|
|
Loading…
Reference in a new issue