-
-
Save oren/7293339 to your computer and use it in GitHub Desktop.
auth
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
var http = require('http'); | |
http.createServer(function (req, res) { | |
if (!authorized(req, res, ['admin'])) { | |
res.statusCode = 401; | |
res.end("You don't have permissions"); | |
} | |
res.statusCode = 200; | |
res.end('Welcome back!'); | |
}).listen(3000); | |
// roles is an array | |
function authorized(req, res, roles) { | |
// acces db to find user's permissions | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment