diff --git a/services/web/app/src/infrastructure/Modules.js b/services/web/app/src/infrastructure/Modules.js index 777c4335c5..a010fd39f9 100644 --- a/services/web/app/src/infrastructure/Modules.js +++ b/services/web/app/src/infrastructure/Modules.js @@ -12,16 +12,23 @@ const _hooks = {} let _viewIncludes = {} function loadModules() { - for (const moduleName of fs.readdirSync(MODULE_BASE_PATH)) { - if (fs.existsSync(Path.join(MODULE_BASE_PATH, moduleName, 'index.js'))) { - const loadedModule = require(Path.join( - MODULE_BASE_PATH, - moduleName, - 'index' - )) - loadedModule.name = moduleName - _modules.push(loadedModule) - } + const settingsCheckModule = Path.join( + MODULE_BASE_PATH, + 'settings-check', + 'index.js' + ) + if (fs.existsSync(settingsCheckModule)) { + require(settingsCheckModule) + } + + for (const moduleName of Settings.moduleImportSequence) { + const loadedModule = require(Path.join( + MODULE_BASE_PATH, + moduleName, + 'index.js' + )) + loadedModule.name = moduleName + _modules.push(loadedModule) } attachHooks() } diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index b51cd07f5a..e8de8a0c57 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -567,10 +567,6 @@ module.exports = { }, reloadModuleViewsOnEachRequest: process.env.NODE_ENV === 'development', - disableModule: { - 'user-activate': process.env.DISABLE_MODULE_USER_ACTIVATE === 'true', - launchpad: process.env.DISABLE_MODULE_LAUNCHPAD === 'true', - }, rateLimit: { autoCompile: { @@ -706,6 +702,8 @@ module.exports = { tprLinkedFileRefreshError: [], }, + moduleImportSequence: ['launchpad', 'user-activate'], + csp: { percentage: parseFloat(process.env.CSP_PERCENTAGE) || 0, enabled: process.env.CSP_ENABLED === 'true', diff --git a/services/web/modules/launchpad/app/src/LaunchpadRouter.js b/services/web/modules/launchpad/app/src/LaunchpadRouter.js index db9bbb1666..5c88c9fbf4 100644 --- a/services/web/modules/launchpad/app/src/LaunchpadRouter.js +++ b/services/web/modules/launchpad/app/src/LaunchpadRouter.js @@ -10,17 +10,12 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ const logger = require('logger-sharelatex') -const Settings = require('@overleaf/settings') const LaunchpadController = require('./LaunchpadController') const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController') const AuthorizationMiddleware = require('../../../../app/src/Features/Authorization/AuthorizationMiddleware') module.exports = { apply(webRouter, apiRouter) { - if (Settings.disableModule.launchpad) { - logger.log({}, 'Skipping Init launchpad router') - return - } logger.log({}, 'Init launchpad router') webRouter.get('/launchpad', LaunchpadController.launchpadPage) diff --git a/services/web/modules/user-activate/app/src/UserActivateRouter.js b/services/web/modules/user-activate/app/src/UserActivateRouter.js index ce5dea9468..18ebaeb9c3 100644 --- a/services/web/modules/user-activate/app/src/UserActivateRouter.js +++ b/services/web/modules/user-activate/app/src/UserActivateRouter.js @@ -1,14 +1,9 @@ const logger = require('logger-sharelatex') -const Settings = require('@overleaf/settings') const UserActivateController = require('./UserActivateController') const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController') module.exports = { apply(webRouter) { - if (Settings.disableModule['user-activate']) { - logger.log({}, 'Skipping Init UserActivate router') - return - } logger.log({}, 'Init UserActivate router') webRouter.get('/user/activate', UserActivateController.activateAccountPage)