Skip to content

Instantly share code, notes, and snippets.

Created Nov 3, 2013
What would you like to do?
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!');
// 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