Skip to content

Commit

Permalink
#5 [feat] create check admin middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
OH-GITAEK committed May 28, 2024
1 parent 2e7e90d commit 57e78d8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/middlewares/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const adminMiddleware = (req, res, next) => {
if (!req.user) {
return res.status(403).json({ message: "Access denied, empty user" });
}
if (!req.user.isAdmin) {
return res.status(403).json({ message: "Access denied, admin only" });
}
next();
};

module.exports = adminMiddleware;

0 comments on commit 57e78d8

Please sign in to comment.