diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json
index a57f1ace3c..4ca762c2f4 100644
--- a/services/web/frontend/extracted-translations.json
+++ b/services/web/frontend/extracted-translations.json
@@ -2,6 +2,7 @@
"access_your_projects_with_git": "",
"account_not_linked_to_dropbox": "",
"account_settings": "",
+ "acct_linked_to_institution_acct_2": "",
"add_another_email": "",
"add_files": "",
"add_new_email": "",
@@ -22,6 +23,7 @@
"beta_program_benefits": "",
"blocked_filename": "",
"can_edit": "",
+ "can_link_your_institution_acct_2": "",
"cancel": "",
"cannot_invite_non_user": "",
"cannot_invite_self": "",
@@ -87,6 +89,7 @@
"dismiss": "",
"dismiss_error_popup": "",
"doesnt_match": "",
+ "doing_this_allow_log_in_through_institution_2": "",
"doing_this_will_verify_affiliation_and_allow_log_in_2": "",
"done": "",
"download": "",
@@ -219,6 +222,7 @@
"let_us_know": "",
"limited_offer": "",
"link": "",
+ "link_accounts": "",
"link_accounts_and_add_email": "",
"link_sharing_is_off": "",
"link_sharing_is_on": "",
diff --git a/services/web/frontend/js/features/settings/components/emails/add-email.tsx b/services/web/frontend/js/features/settings/components/emails/add-email.tsx
index 823b0ae845..fca3c004ea 100644
--- a/services/web/frontend/js/features/settings/components/emails/add-email.tsx
+++ b/services/web/frontend/js/features/settings/components/emails/add-email.tsx
@@ -10,7 +10,7 @@ import SsoLinkingInfo from './add-email/sso-linking-info'
import AddNewEmailBtn from './add-email/add-new-email-btn'
import useAsync from '../../../../shared/hooks/use-async'
import { useUserEmailsContext } from '../../context/user-email-context'
-import { isSsoAvailable } from '../../utils/sso'
+import { ssoAvailableForDomain } from '../../utils/sso'
import { postJSON } from '../../../../infrastructure/fetch-json'
import { University } from '../../../../../../types/university'
import { CountryCode } from '../../data/countries-list'
@@ -120,7 +120,7 @@ function AddEmail() {
/>
- {isSsoAvailable(newEmailMatchedInstitution) ? (
+ {ssoAvailableForDomain(newEmailMatchedInstitution) ? (
+
+
+
+
+
+
+
+ {userEmailData.affiliation?.institution && (
+
+
+
+ )}
+
+
+
+
+
+
+
+
+ {hasSSOAffiliation && (
+
+ )}
+ >
+ )
+}
+
+type SSOAffiliationInfoProps = {
+ userEmailData: UserEmailData
+}
+
+function SSOAffiliationInfo({ userEmailData }: SSOAffiliationInfoProps) {
+ const { samlInitPath } = getMeta('ol-ExposedSettings') as ExposedSettings
+ const { t } = useTranslation()
+ const { state } = useUserEmailsContext()
+
+ if (
+ !userEmailData.samlProviderId &&
+ institutionAlreadyLinked(state, userEmailData)
+ ) {
+ // if the email is not linked to the institution, but there's another email already linked to that institution
+ // no SSO affiliation is displayed, since cannot have multiple emails linked to the same institution
+ return null
+ }
+
+ if (userEmailData.samlProviderId) {
+ return (
+
+
+
+
+ ]
+ }
+ values={{
+ institutionName: userEmailData.affiliation?.institution.name,
+ }}
+ />
+
+
+
+
+ )
+ }
+
return (
-
-
-
-
-
-
- {userEmailData.affiliation?.institution && (
-
-
-
- )}
-
-
-
-
-
+
+
+
+
+
+
+ ]
+ }
+ />
+
+
+ ]
+ }
+ />{' '}
+
+ {t('find_out_more_about_institution_login')}
+
+
+
+
+
+
+
+ {t('link_accounts')}
+
+
+
+
)
diff --git a/services/web/frontend/js/features/settings/utils/sso.ts b/services/web/frontend/js/features/settings/utils/sso.ts
index 72cfdc19ef..82aff98942 100644
--- a/services/web/frontend/js/features/settings/utils/sso.ts
+++ b/services/web/frontend/js/features/settings/utils/sso.ts
@@ -1,9 +1,9 @@
import getMeta from '../../../utils/meta'
import { InstitutionInfo } from '../components/emails/add-email/input'
import { ExposedSettings } from '../../../../../types/exposed-settings'
-import { Nullable } from '../../../../../types/utils'
+import { Institution } from '../../../../../types/institution'
-const ssoAvailableForDomain = (domain: InstitutionInfo | null) => {
+export const ssoAvailableForDomain = (domain: InstitutionInfo | null) => {
const { hasSamlBeta, hasSamlFeature } = getMeta(
'ol-ExposedSettings'
) as ExposedSettings
@@ -16,8 +16,20 @@ const ssoAvailableForDomain = (domain: InstitutionInfo | null) => {
return hasSamlBeta && domain.university.ssoBeta
}
-export const isSsoAvailable = (
- institutionInfo: Nullable
-): institutionInfo is InstitutionInfo => {
- return Boolean(institutionInfo && ssoAvailableForDomain(institutionInfo))
+export const ssoAvailableForInstitution = (institution: Institution | null) => {
+ const { hasSamlBeta, hasSamlFeature } = getMeta(
+ 'ol-ExposedSettings'
+ ) as ExposedSettings
+ if (
+ !hasSamlFeature ||
+ !institution ||
+ !institution.confirmed ||
+ !institution.isUniversity
+ ) {
+ return false
+ }
+ if (institution.ssoEnabled) {
+ return true
+ }
+ return hasSamlBeta && institution.ssoBeta
}
diff --git a/services/web/locales/en.json b/services/web/locales/en.json
index 3514122e31..cafee760cd 100644
--- a/services/web/locales/en.json
+++ b/services/web/locales/en.json
@@ -209,6 +209,7 @@
"institution_email_new_to_app": "Your __institutionName__ email (__email__) is new to __appName__.",
"institutional": "Institutional",
"doing_this_allow_log_in_through_institution": "Doing this will allow you to log in to __appName__ through your institution portal and will reconfirm your institutional email address.",
+ "doing_this_allow_log_in_through_institution_2": "Doing this will allow you to log in to <0>__appName__0> through your institution portal and will reconfirm your institutional email address.",
"doing_this_will_verify_affiliation_and_allow_log_in": "Doing this will verify your affiliation with __institutionName__ and will allow you to log in to __appName__ through your institution.",
"doing_this_will_verify_affiliation_and_allow_log_in_2": "Doing this will verify your affiliation with <0>__institutionName__0> and will allow you to log in to <0>__appName__0> through your institution.",
"email_already_associated_with": "The __email1__ email is already associated with the __email2__ __appName__ account.",
@@ -221,6 +222,7 @@
"can_link_institution_email_by_clicking": "You can link your __email__ __appName__ account to your __institutionName__ account by clicking __clickText__.",
"can_link_institution_email_to_login": "You can link your __email__ __appName__ account to your __institutionName__ account, which will allow you to log in to __appName__ through your institution portal and will reconfirm your institutional email address.",
"can_link_your_institution_acct": "You can now link your __appName__ account to your __institutionName__ institutional account.",
+ "can_link_your_institution_acct_2": "You can now <0>link0> your <0>__appName__0> account to your <0>__institutionName__0> institutional account.",
"can_now_link_to_institution_acct": "You can link your __email__ __appName__ account to your __institutionName__ institutional account.",
"click_link_to_proceed": "Click __clickText__ below to proceed.",
"continue_with_email": "Continue to __appName__ with your __email__ account",
@@ -231,6 +233,7 @@
"account_linking": "Account Linking",
"account_with_email_exists": "It looks like an __appName__ account with the email __email__ already exists.",
"acct_linked_to_institution_acct": "You can log in to Overleaf through your __institutionName__ institutional login.",
+ "acct_linked_to_institution_acct_2": "You can <0>log in0> to Overleaf through your <0>__institutionName__0> institutional login.",
"alternatively_create_new_institution_account": "Alternatively, you can create a new account with your institution email (__email__) by clicking __clickText__.",
"as_a_member_of_sso": "As a member of __institutionName__, you can log in to __appName__ through your institution portal.",
"as_a_member_of_sso_required": "As a member of __institutionName__, you must log in to __appName__ through your institution portal.",
|