sso.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import getMeta from '../../../utils/meta'
  2. import { DomainInfo } from '../components/emails/add-email/input'
  3. import { Institution } from '../../../../../types/institution'
  4. export const ssoAvailableForDomain = (
  5. domain: DomainInfo | null,
  6. isDomainCapturedByGroup: boolean
  7. ): domain is DomainInfo => {
  8. const { hasSamlBeta, hasSamlFeature } = getMeta('ol-ExposedSettings')
  9. if (!hasSamlFeature || !domain || !domain.confirmed || !domain.university) {
  10. return false
  11. }
  12. if (domain.university.ssoEnabled) {
  13. return true
  14. }
  15. if (isDomainCapturedByGroup && domain.group?.ssoConfig?.enabled) {
  16. return true
  17. }
  18. return Boolean(hasSamlBeta && domain.university.ssoBeta)
  19. }
  20. export const ssoAvailableForInstitution = (institution: Institution | null) => {
  21. const { hasSamlBeta, hasSamlFeature } = getMeta('ol-ExposedSettings')
  22. if (!hasSamlFeature || !institution || !institution.confirmed) {
  23. return false
  24. }
  25. if (institution.ssoEnabled) {
  26. return true
  27. }
  28. return hasSamlBeta && institution.ssoBeta
  29. }