LaunchpadRouter.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* eslint-disable
  2. max-len,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * DS207: Consider shorter variations of null checks
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. const logger = require('logger-sharelatex')
  13. const Settings = require('settings-sharelatex')
  14. const LaunchpadController = require('./LaunchpadController')
  15. const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController')
  16. const AuthorizationMiddleware = require('../../../../app/src/Features/Authorization/AuthorizationMiddleware')
  17. module.exports = {
  18. apply(webRouter, apiRouter) {
  19. if (Settings.disableModule.launchpad) {
  20. logger.log({}, 'Skipping Init launchpad router')
  21. return
  22. }
  23. logger.log({}, 'Init launchpad router')
  24. webRouter.get('/launchpad', LaunchpadController.launchpadPage)
  25. webRouter.post(
  26. '/launchpad/register_admin',
  27. LaunchpadController.registerAdmin
  28. )
  29. webRouter.post(
  30. '/launchpad/register_ldap_admin',
  31. LaunchpadController.registerExternalAuthAdmin('ldap')
  32. )
  33. webRouter.post(
  34. '/launchpad/register_saml_admin',
  35. LaunchpadController.registerExternalAuthAdmin('saml')
  36. )
  37. webRouter.post(
  38. '/launchpad/send_test_email',
  39. AuthorizationMiddleware.ensureUserIsSiteAdmin,
  40. LaunchpadController.sendTestEmail
  41. )
  42. if (AuthenticationController.addEndpointToLoginWhitelist != null) {
  43. AuthenticationController.addEndpointToLoginWhitelist('/launchpad')
  44. AuthenticationController.addEndpointToLoginWhitelist(
  45. '/launchpad/register_admin'
  46. )
  47. AuthenticationController.addEndpointToLoginWhitelist(
  48. '/launchpad/register_ldap_admin'
  49. )
  50. return AuthenticationController.addEndpointToLoginWhitelist(
  51. '/launchpad/register_saml_admin'
  52. )
  53. }
  54. }
  55. }