mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
fix: #12227, fix crash in redirect
This commit is contained in:
@@ -221,6 +221,20 @@ module.exports = function (middleware) {
|
||||
controllers.helpers.redirect(res, path);
|
||||
});
|
||||
|
||||
middleware.redirectToHomeIfBanned = helpers.try(async (req, res, next) => {
|
||||
if (req.loggedIn) {
|
||||
const canLoginIfBanned = await user.bans.canLoginIfBanned(req.uid);
|
||||
if (!canLoginIfBanned) {
|
||||
req.logout(() => {
|
||||
res.redirect('/');
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
middleware.requireUser = function (req, res, next) {
|
||||
if (req.loggedIn) {
|
||||
return next();
|
||||
|
||||
Reference in New Issue
Block a user