mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
aa480a2663
[web] migrate from window attributes to getMeta GitOrigin-RevId: 3dcf1ab6b01155e5e4abeb3e78d0fa9053e055bc
32 lines
948 B
TypeScript
32 lines
948 B
TypeScript
import getMeta from '../../../utils/meta'
|
|
import { DomainInfo } from '../components/emails/add-email/input'
|
|
import { Institution } from '../../../../../types/institution'
|
|
|
|
export const ssoAvailableForDomain = (
|
|
domain: DomainInfo | null
|
|
): domain is DomainInfo => {
|
|
const { hasSamlBeta, hasSamlFeature } = getMeta('ol-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')
|
|
if (
|
|
!hasSamlFeature ||
|
|
!institution ||
|
|
!institution.confirmed ||
|
|
!institution.isUniversity
|
|
) {
|
|
return false
|
|
}
|
|
if (institution.ssoEnabled) {
|
|
return true
|
|
}
|
|
return hasSamlBeta && institution.ssoBeta
|
|
}
|