diff --git a/src/controllers/accounts/follow.js b/src/controllers/accounts/follow.js index 58dba7f3c0..7a28374582 100644 --- a/src/controllers/accounts/follow.js +++ b/src/controllers/accounts/follow.js @@ -14,8 +14,11 @@ followController.getFollowers = async function (req, res, next) { await getFollow('account/followers', 'followers', req, res, next); }; -async function getFollow(tpl, name, req, res) { +async function getFollow(tpl, name, req, res, next) { const { userData: payload } = res.locals; + if (!payload) { + return next(); + } const { username, userslug, followerCount, followingCount, } = payload; diff --git a/src/middleware/user.js b/src/middleware/user.js index 82621bf71e..3b7c1168db 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -260,6 +260,9 @@ module.exports = function (middleware) { } res.locals.userData = await accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, req.query); + if (!res.locals.userData) { + return next('route'); + } next(); };