Created
January 26, 2019 02:49
-
-
Save thameera/534670dcec94c4e54570e5ee1a937b00 to your computer and use it in GitHub Desktop.
Filter AD users based on their groups
This file contains hidden or 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(user, context, callback) { | |
var _ = require('lodash'); | |
var groupsAllowed = ['group1', 'group2', 'group3']; | |
var userHasAccess = _.intersection(user.groups, groupsAllowed) > 0; | |
if (!userHasAccess) { | |
return callback(new UnauthorizedError('Access denied.')); | |
} | |
callback(null, user, context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment