sso.ts 963 B

1234567891011121314151617181920212223242526272829303132
  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. if (domain.group?.ssoConfig?.enabled) {
  15. return true
  16. }
  17. return Boolean(hasSamlBeta && domain.university.ssoBeta)
  18. }
  19. export const ssoAvailableForInstitution = (institution: Institution | null) => {
  20. const { hasSamlBeta, hasSamlFeature } = getMeta('ol-ExposedSettings')
  21. if (!hasSamlFeature || !institution || !institution.confirmed) {
  22. return false
  23. }
  24. if (institution.ssoEnabled) {
  25. return true
  26. }
  27. return hasSamlBeta && institution.ssoBeta
  28. }