Skip to content

Instantly share code, notes, and snippets.

@flaviocopes
Created January 23, 2018 09:19
Show Gist options
  • Save flaviocopes/88ba71b9f819b415dafcf96a4510beec to your computer and use it in GitHub Desktop.
Save flaviocopes/88ba71b9f819b415dafcf96a4510beec to your computer and use it in GitHub Desktop.
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