I'm not able to Add Persistent Attributes To The User

Hello, I’m trying to add a user data to my app delevloped with Angular 5.
I add the login with auth0. I’d like to add some infos when I login like company name.
I follow this link, but i’m not able…

I insert the data on user_metadata

I create a new rule clicking on “Add Persistent Attributes To The User” with the following code:

function (user, context, callback) {
  user.user_metadata = user.user_metadata || {};
  user.user_metadata.cocompanylor = user.user_metadata.company || 'Error';
  context.idToken['https://example.com/favorite_color'] = user.user_metadata.company;

  auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
        callback(null, user, context);

All works but I saw https://example.com/favorite_color and I see the result if I print con console all the profile.
But I want to assign property Company to my local variable…
I tried this.profile.user_metadata but it doesn’t work
How can I do that?

You’re assigning the value of user.user_metadata.company to a custom claim named https://example.com/favorite_color so in order to access that value on the client application you would have to do something like:

var company = this.profile["https://example.com/favorite_color"];

Hello, thanks for your reply!

But I still have problems… the function overwrite the value on user_metadata and company become Error.

also another question: how can i use var_name istead of a url like: https://example.com/favorite_color ?


Hey there!

Sorry for such delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough compared to the number of questions we get.

Are you still battling with the issue and need further assistance?