overleaf-cep/services/web/frontend/js/features/settings/utils/sso.ts
Jessica Lawshe e1a2bccf53 Merge pull request #22967 from overleaf/jel-user-settings-sso-institution
[web]  Fix SSO available check on user settings page

GitOrigin-RevId: e8322eb9d9cacad26054fc4a6186e41f66de7d22
2025-01-23 09:06:30 +00:00

27 lines
899 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) {
return false
}
if (institution.ssoEnabled) {
return true
}
return hasSamlBeta && institution.ssoBeta
}