-
-
Save wmbutler/79d321287ccfda267389 to your computer and use it in GitHub Desktop.
Auth0 role rule
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) { | |
| // You can add a Role based on what you want | |
| // In this case I check domain | |
| var addRolesToUser = function(user, cb) { | |
| if (user.email === 'bill@butler.net') { | |
| cb(null, ['admin']); | |
| } else { | |
| cb(null, ['user']); | |
| } | |
| }; | |
| addRolesToUser(user, function(err, roles) { | |
| if (err) { | |
| callback(err); | |
| } else { | |
| user.persistent.roles = roles; | |
| callback(null, user, context); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment