updated middlewares so if you have not completed registration, you will be required to do so

v1.18.x
Julian Lam 9 years ago
parent 0ba0001f75
commit f03018b7cc

@ -350,6 +350,19 @@ middleware.processTimeagoLocales = function(req, res, next) {
}
};
middleware.registrationComplete = function(req, res, next) {
// If the user's session contains registration data, redirect the user to complete registration
if (!req.session.hasOwnProperty('registration')) {
return next();
} else {
if (!req.path.endsWith('/register/complete')) {
controllers.helpers.redirect(res, '/register/complete');
} else {
return next();
}
}
};
module.exports = function(webserver) {
app = webserver;
middleware.admin = require('./admin')(webserver);

@ -3,7 +3,7 @@
var helpers = {};
helpers.setupPageRoute = function(router, name, middleware, middlewares, controller) {
middlewares = middlewares.concat([middleware.pageView, middleware.pluginHooks]);
middlewares = middlewares.concat([middleware.registrationComplete, middleware.pageView, middleware.pluginHooks]);
router.get(name, middleware.busyCheck, middleware.buildHeader, middlewares, controller);
router.get('/api' + name, middlewares, controller);

@ -28,7 +28,7 @@ function mainRoutes(app, middleware, controllers) {
setupPageRoute(app, '/login', middleware, loginRegisterMiddleware, controllers.login);
setupPageRoute(app, '/register', middleware, loginRegisterMiddleware, controllers.register);
setupPageRoute(app, '/register/complete', middleware, loginRegisterMiddleware, controllers.registerInterstitial);
setupPageRoute(app, '/register/complete', middleware, [], controllers.registerInterstitial);
setupPageRoute(app, '/compose', middleware, [], controllers.compose);
setupPageRoute(app, '/confirm/:code', middleware, [], controllers.confirmEmail);
setupPageRoute(app, '/outgoing', middleware, [], controllers.outgoing);

Loading…
Cancel
Save