aboutsummaryrefslogtreecommitdiffstats
path: root/middleware
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-08-12 17:06:50 +0000
committerpack <pack@packgekko.xyz>2026-08-12 17:06:50 +0000
commit5611527e313c4add16c432e5cf9d55a987558c02 (patch)
tree59ad054325096b6305277b94982bbe7f7f585f59 /middleware
parentd3adc16a08d95d6e331de55d7d3bf05a66a874a8 (diff)
downloadcrud-5611527e313c4add16c432e5cf9d55a987558c02.tar.gz
final commit
Diffstat (limited to 'middleware')
-rw-r--r--middleware/auth.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/middleware/auth.js b/middleware/auth.js
index e69de29..4f98a81 100644
--- a/middleware/auth.js
+++ b/middleware/auth.js
@@ -0,0 +1,10 @@
+function requireAuth(req, res, next)
+{
+ if (req.session.userId)
+ {
+ return next();
+ }
+ res.status(401).json({ error: 'Not authenticated' });
+}
+
+module.exports = requireAuth;