Created
February 20, 2024 20:10
-
-
Save shinecita/3dbffaf861ab9306d5caab543521ea43 to your computer and use it in GitHub Desktop.
Authorization middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isAuthorized(req, res, next) { | |
if (req.headers.authorization) { | |
// compare access token with db | |
if (everythingok) | |
RETURN next() | |
} | |
if (!req.user) { | |
res.status(401).json({error: reason}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment