Hello!
I currently have an Auth0 SPA React application, which I made following this tutorial: Add Login to Your React Application - Auth0 Docs
How do I get the defined user permissions of a user when a user is successfully authenticated?
The Auth0Client.getUser() does not provide this.
Greetings
markd
February 7, 2020, 3:58pm
2
Hello @glennydc ,
Welcome to the Community!
getUser() reads the data in the ID token. You can add additional user profile attributes to the ID token using a rule . For example, here is a sample rule that adds the attribute app_metadata.uuid (assuming such an attribute exists) to the ID token:
function (user, context, callback) {
// recommended namespace is a URL-formatted string
// var namespace = "https://${YOUR_DOMAIN}/claims/"
var namespace = "https://sr2.ca/claims/";
user.app_metadata = user.app_metadata || {};
user.app_metadata.uuid = user.app_metadata.uuid || {};
context.idToken[namespace + "uuid"] = user.app_metadata.uuid;
callback(null, user, context);
}
1 Like