Skip to content

Commit

Permalink
fix: #7125, allow list for page route, configurable via plugin hook
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Jan 25, 2021
1 parent 8b72479 commit f975063
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/middleware/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,17 @@ module.exports = function (middleware) {
res.status(403).render('403', { title: '[[global:403.title]]' });
};

middleware.registrationComplete = function registrationComplete(req, res, next) {
middleware.registrationComplete = async function registrationComplete(req, res, next) {
// If the user's session contains registration data, redirect the user to complete registration
if (!req.session.hasOwnProperty('registration')) {
return setImmediate(next);
}
if (!req.path.endsWith('/register/complete')) {

const path = req.path.startsWith('/api/') ? req.path.replace('/api', '') : req.path;
const { allowed } = await plugins.hooks.fire('filter:middleware.registrationComplete', {
allowed: ['/register/complete'],
});
if (!allowed.includes(path)) {
// Append user data if present
req.session.registration.uid = req.uid;

Expand Down

0 comments on commit f975063

Please sign in to comment.