Merge pull request #2337 from overleaf/jel-saml-already-linked

Institution linking and unlinking

GitOrigin-RevId: 1c3665fc66513c3e88a62ed477800c17759459ff
This commit is contained in:
Eric Mc Sween
2019-11-12 08:59:04 -05:00
committed by sharelatex
parent 3bd15b1a47
commit b5d7887dfb
5 changed files with 59 additions and 5 deletions

View File

@@ -497,7 +497,7 @@ const ProjectController = {
// Notification: After SSO Linked or Logging in
// The requested email does not match primary email returned from
// the institution
if (samlSession.emailNonCanonical) {
if (samlSession.emailNonCanonical && !samlSession.linkedToAnother) {
notificationsInstitution.push({
institutionEmail: samlSession.emailNonCanonical,
requestedEmail: samlSession.requestedEmail,
@@ -509,12 +509,23 @@ const ProjectController = {
// 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) {
if (
samlSession.registerIntercept &&
samlSession.institutionEmail &&
!samlSession.linkedToAnother
) {
notificationsInstitution.push({
email: samlSession.institutionEmail,
templateKey: 'notification_institution_sso_already_registered'
})
}
// Notification: Already linked to another account
if (samlSession.linkedToAnother) {
notificationsInstitution.push({
templateKey: 'notification_institution_sso_linked_by_another'
})
}
}
delete req.session.saml
}