sso.ts 1.0 KB

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