sso.ts 899 B

123456789101112131415161718192021222324252627
  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. ): domain is DomainInfo => {
  7. const { hasSamlBeta, hasSamlFeature } = getMeta('ol-ExposedSettings')
  8. if (!hasSamlFeature || !domain || !domain.confirmed || !domain.university) {
  9. return false
  10. }
  11. if (domain.university.ssoEnabled) {
  12. return true
  13. }
  14. return Boolean(hasSamlBeta && domain.university.ssoBeta)
  15. }
  16. export const ssoAvailableForInstitution = (institution: Institution | null) => {
  17. const { hasSamlBeta, hasSamlFeature } = getMeta('ol-ExposedSettings')
  18. if (!hasSamlFeature || !institution || !institution.confirmed) {
  19. return false
  20. }
  21. if (institution.ssoEnabled) {
  22. return true
  23. }
  24. return hasSamlBeta && institution.ssoBeta
  25. }