Set redirect when sending user to login page.

Allows smart redirecting to work when public access is turned off.
This commit is contained in:
Shane Kilkelly 2017-01-10 15:42:36 +00:00
parent 0b67265eb6
commit f5ced03074
2 changed files with 8 additions and 0 deletions

View file

@ -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)->

View file

@ -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"