UNPKG

authkit-js

Version:

Express auth toolkit (JWT, Sessions with Redis, Google/GitHub OAuth) in JavaScript

8 lines (7 loc) 215 B
function requireAuth() { return function (req, res, next) { if (!req.auth || !req.auth.user) return res.status(401).json({ error: 'Unauthorized' }); next(); }; } module.exports = { requireAuth };