mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 02:00:10 +02:00
[web] Check if domain is captured by group when using domain API GitOrigin-RevId: 6e14df0a1701c33fc80f21f01bb3fbb446d7f074
33 lines
963 B
TypeScript
33 lines
963 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
|
|
}
|
|
|
|
if (domain.group?.ssoConfig?.enabled) {
|
|
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) {
|
|
return false
|
|
}
|
|
if (institution.ssoEnabled) {
|
|
return true
|
|
}
|
|
return hasSamlBeta && institution.ssoBeta
|
|
}
|