LaunchpadRouter.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 LaunchpadController = require('./LaunchpadController')
  14. const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController')
  15. const AuthorizationMiddleware = require('../../../../app/src/Features/Authorization/AuthorizationMiddleware')
  16. module.exports = {
  17. apply(webRouter, apiRouter) {
  18. logger.log({}, 'Init launchpad router')
  19. webRouter.get('/launchpad', LaunchpadController.launchpadPage)
  20. webRouter.post(
  21. '/launchpad/register_admin',
  22. LaunchpadController.registerAdmin
  23. )
  24. webRouter.post(
  25. '/launchpad/register_ldap_admin',
  26. LaunchpadController.registerExternalAuthAdmin('ldap')
  27. )
  28. webRouter.post(
  29. '/launchpad/register_saml_admin',
  30. LaunchpadController.registerExternalAuthAdmin('saml')
  31. )
  32. webRouter.post(
  33. '/launchpad/send_test_email',
  34. AuthorizationMiddleware.ensureUserIsSiteAdmin,
  35. LaunchpadController.sendTestEmail
  36. )
  37. if (AuthenticationController.addEndpointToLoginWhitelist != null) {
  38. AuthenticationController.addEndpointToLoginWhitelist('/launchpad')
  39. AuthenticationController.addEndpointToLoginWhitelist(
  40. '/launchpad/register_admin'
  41. )
  42. AuthenticationController.addEndpointToLoginWhitelist(
  43. '/launchpad/register_ldap_admin'
  44. )
  45. return AuthenticationController.addEndpointToLoginWhitelist(
  46. '/launchpad/register_saml_admin'
  47. )
  48. }
  49. },
  50. }