Przeglądaj źródła

Merge pull request #2993 from overleaf/jpa-drop-private-api-usage

[misc] launchpad: refactor private api usage of AuthenticationController

GitOrigin-RevId: 74585bcf7bf7483ae19af7b341e1173293d667fe
Hugh O'Brien 6 lat temu
rodzic
commit
ff2ee573bb

+ 2 - 1
services/web/modules/launchpad/app/src/LaunchpadController.js

@@ -54,7 +54,8 @@ module.exports = LaunchpadController = {
             authMethod
             authMethod
           })
           })
         } else {
         } else {
-          return AuthenticationController._redirectToLoginPage(req, res)
+          AuthenticationController.setRedirectInSession(req)
+          return res.redirect('/login')
         }
         }
       } else {
       } else {
         return UserGetter.getUser(sessionUser._id, { isAdmin: 1 }, function(
         return UserGetter.getUser(sessionUser._id, { isAdmin: 1 }, function(

+ 4 - 2
services/web/modules/launchpad/test/unit/src/LaunchpadControllerTests.js

@@ -62,6 +62,7 @@ describe('LaunchpadController', function() {
 
 
     this.res = {
     this.res = {
       render: sinon.stub(),
       render: sinon.stub(),
+      redirect: sinon.stub(),
       send: sinon.stub(),
       send: sinon.stub(),
       sendStatus: sinon.stub()
       sendStatus: sinon.stub()
     }
     }
@@ -75,7 +76,7 @@ describe('LaunchpadController', function() {
         this.LaunchpadController,
         this.LaunchpadController,
         '_atLeastOneAdminExists'
         '_atLeastOneAdminExists'
       )
       )
-      return (this.AuthenticationController._redirectToLoginPage = sinon.stub())
+      return (this.AuthenticationController.setRedirectInSession = sinon.stub())
     })
     })
 
 
     afterEach(function() {
     afterEach(function() {
@@ -126,9 +127,10 @@ describe('LaunchpadController', function() {
         })
         })
 
 
         it('should redirect to login page', function() {
         it('should redirect to login page', function() {
-          return this.AuthenticationController._redirectToLoginPage.callCount.should.equal(
+          this.AuthenticationController.setRedirectInSession.callCount.should.equal(
             1
             1
           )
           )
+          this.res.redirect.calledWith('/login').should.equal(true)
         })
         })
 
 
         it('should not render the launchpad page', function() {
         it('should not render the launchpad page', function() {