Features.coffee 937 B

12345678910111213141516171819202122232425262728293031
  1. Settings = require 'settings-sharelatex'
  2. module.exports = Features =
  3. externalAuthenticationSystemUsed: ->
  4. Settings.ldap? or Settings.saml? or Settings.overleaf?.oauth?
  5. hasFeature: (feature) ->
  6. switch feature
  7. when 'homepage'
  8. return Settings.enableHomepage
  9. when 'registration'
  10. return not Features.externalAuthenticationSystemUsed()
  11. when 'github-sync'
  12. return Settings.enableGithubSync
  13. when 'v1-return-message'
  14. return Settings.accountMerge? and Settings.overleaf?
  15. when 'v2-banner'
  16. return Settings.showV2Banner
  17. when 'custom-togglers'
  18. return Settings.overleaf?
  19. when 'templates'
  20. return !Settings.overleaf?
  21. when 'affiliations'
  22. return Settings?.apis?.v1?.url?
  23. when 'rich-text'
  24. isEnabled = true # Switch to false to disable
  25. Settings.overleaf? and isEnabled
  26. when 'redirect-sl'
  27. return Settings.redirectToV2?
  28. else
  29. throw new Error("unknown feature: #{feature}")