Skip to content

Commit

Permalink
fix: #7816, adding GDPR and TOU interstitials earlier on route reloading
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julianlam committed Aug 2, 2019
1 parent 687b9b7 commit 52a2e5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 0 additions & 2 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
};
Expand Down

0 comments on commit 52a2e5d

Please sign in to comment.