2022-05-11 05:19:10 -04:00
|
|
|
import getMeta from '../../../utils/meta'
|
2022-05-26 04:32:43 -04:00
|
|
|
import { DomainInfo } from '../components/emails/add-email/input'
|
2022-05-11 05:19:10 -04:00
|
|
|
import { ExposedSettings } from '../../../../../types/exposed-settings'
|
2022-05-24 07:12:39 -04:00
|
|
|
import { Institution } from '../../../../../types/institution'
|
2022-05-11 05:19:10 -04:00
|
|
|
|
2022-05-31 05:08:49 -04:00
|
|
|
export const ssoAvailableForDomain = (
|
|
|
|
domain: DomainInfo | null
|
|
|
|
): domain is DomainInfo => {
|
2022-05-11 05:19:10 -04:00
|
|
|
const { hasSamlBeta, hasSamlFeature } = getMeta(
|
|
|
|
'ol-ExposedSettings'
|
|
|
|
) as ExposedSettings
|
|
|
|
if (!hasSamlFeature || !domain || !domain.confirmed || !domain.university) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (domain.university.ssoEnabled) {
|
|
|
|
return true
|
|
|
|
}
|
2022-05-31 05:08:49 -04:00
|
|
|
return Boolean(hasSamlBeta && domain.university.ssoBeta)
|
2022-05-11 05:19:10 -04:00
|
|
|
}
|
|
|
|
|
2022-05-24 07:12:39 -04:00
|
|
|
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
|
2022-05-11 05:19:10 -04:00
|
|
|
}
|