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.
v1.18.x
Julian Lam 6 years ago
parent 687b9b74c0
commit 52a2e5d61d

@ -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 */

@ -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');
};

Loading…
Cancel
Save