Favorieten toegevoegd aan de navigatiebalk en sidebar.
This commit is contained in:
+12
-8
@@ -4,17 +4,21 @@ require("../repositories/UserRepository");
|
||||
|
||||
module.exports = function userMiddleware(req, res, next) {
|
||||
|
||||
req.user = null;
|
||||
|
||||
if (req.session.userId) {
|
||||
|
||||
req.user =
|
||||
UserRepository.findById(
|
||||
req.session.userId
|
||||
);
|
||||
|
||||
if (!req.session || !req.session.userId) {
|
||||
return next();
|
||||
}
|
||||
|
||||
req.user = UserRepository.findById(req.session.userId);
|
||||
|
||||
next();
|
||||
if (!req.user) {
|
||||
delete req.session.userId;
|
||||
if (typeof req.session.destroy === "function") {
|
||||
return req.session.destroy(() => next());
|
||||
}
|
||||
}
|
||||
|
||||
return next();
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user