overleaf/services/web/frontend/js/features/settings/utils/sso.ts
ilkin-overleaf c807bedb65 Merge pull request #7841 from overleaf/ii-refactor-add-email
Refactor add email section

GitOrigin-RevId: 41de440caaf3baf43673c4a5f07a18b990f28c7b
2022-05-12 08:03:29 +00:00

23 lines
816 B
TypeScript

import getMeta from '../../../utils/meta'
import { InstitutionInfo } from '../components/emails/add-email/input'
import { ExposedSettings } from '../../../../../types/exposed-settings'
import { Nullable } from '../../../../../types/utils'
const ssoAvailableForDomain = (domain: InstitutionInfo | null) => {
const { hasSamlBeta, hasSamlFeature } = getMeta(
'ol-ExposedSettings'
) as ExposedSettings
if (!hasSamlFeature || !domain || !domain.confirmed || !domain.university) {
return false
}
if (domain.university.ssoEnabled) {
return true
}
return hasSamlBeta && domain.university.ssoBeta
}
export const isSsoAvailable = (
institutionInfo: Nullable<InstitutionInfo>
): institutionInfo is InstitutionInfo => {
return Boolean(institutionInfo && ssoAvailableForDomain(institutionInfo))
}