Skip to content

Instantly share code, notes, and snippets.

@abbaspour
Last active October 10, 2018 21:24
Show Gist options
  • Select an option

  • Save abbaspour/ecea4d6a91560f8594323d823ed70ca8 to your computer and use it in GitHub Desktop.

Select an option

Save abbaspour/ecea4d6a91560f8594323d823ed70ca8 to your computer and use it in GitHub Desktop.
extend access token
function (user, context, callback) {
let role = user.app_metadata.role || 'limied-authority';
if (role === 'legal-lessee' || role === 'full-authority')
context.accessToken.scope = ['read:usage', 'read:bill', 'pay:bill', 'update:email'];
else
context.accessToken.scope = ['read:bill'];
context.accessToken['http://custom.ns/role'] = role; // plain text role, for audit
callback(null, user, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment