Created
January 23, 2018 09:19
-
-
Save flaviocopes/88ba71b9f819b415dafcf96a4510beec to your computer and use it in GitHub Desktop.
This file contains 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) { | |
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