Skip to content

Instantly share code, notes, and snippets.

@wmbutler
Created November 17, 2014 17:28
Show Gist options
  • Select an option

  • Save wmbutler/79d321287ccfda267389 to your computer and use it in GitHub Desktop.

Select an option

Save wmbutler/79d321287ccfda267389 to your computer and use it in GitHub Desktop.
Auth0 role rule
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