Skip to content

Instantly share code, notes, and snippets.

@flaviocopes
Created January 23, 2018 09:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
function (user, context, callback) {
if (context.clientName !== 'YOURAPPNAME') {
return callback(null, user, context);
}
var whitelist = ['info@example.com', 'owner@example.org']; //authorized emails
var userHasAccess = whitelist.some(
function (email) {
return user.email.toLowerCase() === email;
});
if (!userHasAccess) {
return callback(new UnauthorizedError('Access denied.'));
}
return callback(null, user, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment