overleaf/services/web/frontend/js/features/settings/utils/sso.ts
ilkin-overleaf e41315364d Merge pull request #8226 from overleaf/ae-remaining-types
[web] Fix remaining strict type checks

GitOrigin-RevId: 69881c37938f88c7ea4a630f362712a804085bc8
2022-06-01 08:03:29 +00:00

37 lines
1 KiB
TypeScript

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