mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-11 18:36:58 -05:00
24 lines
816 B
TypeScript
24 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))
|
||
|
}
|