Merge pull request #2350 from overleaf/jel-institution-notifications

Non canonical notification when initiated at institution

GitOrigin-RevId: 486f740bf6f71012d479c69176efbf28d6883b8d
This commit is contained in:
Jessica Lawshe 2019-11-13 08:22:54 -06:00 committed by sharelatex
parent af63c8de97
commit 7ad4b2cfc3
3 changed files with 35 additions and 2 deletions

View file

@ -497,7 +497,11 @@ const ProjectController = {
// Notification: After SSO Linked or Logging in
// The requested email does not match primary email returned from
// the institution
if (samlSession.emailNonCanonical && !samlSession.linkedToAnother) {
if (
samlSession.requestedEmail &&
samlSession.emailNonCanonical &&
!samlSession.linkedToAnother
) {
notificationsInstitution.push({
institutionEmail: samlSession.emailNonCanonical,
requestedEmail: samlSession.requestedEmail,

View file

@ -132,6 +132,10 @@ const UserPagesController = {
'saml',
'emailNonCanonical'
])
const institutionRequestedEmail = _.get(req.session, [
'saml',
'requestedEmail'
])
delete req.session.saml
logger.log({ user: userId }, 'loading settings page')
let shouldAllowEditingDetails = true
@ -161,7 +165,10 @@ const UserPagesController = {
oauthUseV2: Settings.oauthUseV2 || false,
institutionLinked,
institutionLinkedToAnother,
institutionEmailNonCanonical,
institutionEmailNonCanonical:
institutionEmailNonCanonical && institutionRequestedEmail
? institutionEmailNonCanonical
: undefined,
samlBeta: req.session.samlBeta,
ssoError: ssoError,
thirdPartyIds: UserPagesController._restructureThirdPartyIds(user)

View file

@ -800,6 +800,28 @@ describe('ProjectController', function() {
}
this.ProjectController.projectListPage(this.req, this.res)
})
describe('when linking/logging in initiated on institution side', function() {
it('should not show a linked another email notification', function() {
// this is only used when initated on Overleaf,
// because we keep track of the requested email they tried to link
this.res.render = (pageName, opts) => {
expect(opts.notificationsInstitution).to.not.deep.include({
institutionEmail: this.institutionEmail,
requestedEmail: undefined,
templateKey: 'notification_institution_sso_non_canonical'
})
}
this.req.session.saml = {
emailNonCanonical: this.institutionEmail,
institutionEmail: this.institutionEmail,
linked: {
hasEntitlement: false,
universityName: this.institutionName
}
}
this.ProjectController.projectListPage(this.req, this.res)
})
})
})
describe('When Institution SSO is not released', function() {