Skip to content

Instantly share code, notes, and snippets.

@oren
Created Nov 3, 2013
Embed
What would you like to do?
auth
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