From 52a2e5d61d7b3e80e83107efa884e698a2dc06fd Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 2 Aug 2019 12:57:02 -0400 Subject: [PATCH] fix: #7816, adding GDPR and TOU interstitials earlier on route reloading A use-case was presented that called for a theme to disable the registration interstitials. However, the plugin hooks were always fired first, and so the core interstitials could not be removed at that time because they hadn't been added yet. This change moved the interstitial adding to the earliest point possible, right after plugins.loadedHooks is emptied in preparation for plugin initialisation. --- src/plugins/index.js | 4 ++++ src/routes/index.js | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/index.js b/src/plugins/index.js index a1d1fcac1e..ee5dd30f90 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -8,6 +8,8 @@ const semver = require('semver'); const nconf = require('nconf'); const util = require('util'); +const user = require('../user'); + const readdirAsync = util.promisify(fs.readdir); var app; @@ -104,6 +106,8 @@ Plugins.reload = async function () { Plugins.libraryPaths.length = 0; Plugins.loadedPlugins.length = 0; + await user.addInterstitials(); + const paths = await Plugins.getPluginPaths(); for (const path of paths) { /* eslint-disable no-await-in-loop */ diff --git a/src/routes/index.js b/src/routes/index.js index 3a9bc4db56..561ae8ee1f 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -8,7 +8,6 @@ var express = require('express'); var meta = require('../meta'); var controllers = require('../controllers'); var plugins = require('../plugins'); -var user = require('../user'); var accountRoutes = require('./accounts'); var metaRoutes = require('./meta'); @@ -111,7 +110,6 @@ module.exports = async function (app, middleware) { await plugins.reloadRoutes({ router: router }); await authRoutes.reloadRoutes({ router: router }); addCoreRoutes(app, router, middleware); - await user.addInterstitials(); winston.info('Routes added'); };