Răsfoiți Sursa

Merge pull request #2300 from overleaf/jel-institution-register

Institution SSO register notification

GitOrigin-RevId: 6838b4f950f9841911da97234d1292802d3ea451
Jessica Lawshe 7 ani în urmă
părinte
comite
67a5f08192

+ 4 - 1
services/web/app/src/Features/Project/ProjectController.js

@@ -506,7 +506,10 @@ const ProjectController = {
             }
             }
 
 
             // Notification: Tried to register, but account already existed
             // Notification: Tried to register, but account already existed
-            if (samlSession.registerIntercept) {
+            // registerIntercept is set before the institution callback.
+            // institutionEmail is set after institution callback.
+            // Check for both in case SSO flow was abandoned
+            if (samlSession.registerIntercept && samlSession.institutionEmail) {
               notificationsInstitution.push({
               notificationsInstitution.push({
                 email: samlSession.institutionEmail,
                 email: samlSession.institutionEmail,
                 templateKey: 'notification_institution_sso_already_registered'
                 templateKey: 'notification_institution_sso_already_registered'

+ 21 - 1
services/web/test/unit/src/Project/ProjectControllerTests.js

@@ -747,7 +747,27 @@ describe('ProjectController', function() {
             hasEntitlement: false,
             hasEntitlement: false,
             universityName: 'Overleaf'
             universityName: 'Overleaf'
           },
           },
-          registerIntercept: true
+          registerIntercept: {
+            id: 1,
+            name: 'Example University'
+          }
+        }
+        this.ProjectController.projectListPage(this.req, this.res)
+      })
+      it('should not show a register notification if the flow was abandoned', function() {
+        // could initially start to register with an SSO email and then
+        // abandon flow and login with an existing non-institution SSO email
+        this.res.render = (pageName, opts) => {
+          expect(opts.notificationsInstitution).to.deep.not.include({
+            email: 'test@overleaf.com',
+            templateKey: 'notification_institution_sso_already_registered'
+          })
+        }
+        this.req.session.saml = {
+          registerIntercept: {
+            id: 1,
+            name: 'Example University'
+          }
         }
         }
         this.ProjectController.projectListPage(this.req, this.res)
         this.ProjectController.projectListPage(this.req, this.res)
       })
       })