Roles for users how to read how to write

Hi all,

I’m new here and in the authorisation in general.

I’m trying to assign a role to the user and then read it on a client. I use Vue and npm auth0, not a special Vue adaptation. I’ve made the simple authorisation works, thanks to the explicit lessons on this resource. I have successfully made a rule, at least it passed the tests.

Now I stuck with the question what to do next. I can not read roles in my app, although I see there is one by default in the user profile. The rule I’ve made pass the test but do not assign the right role. Maybe I send a wrong request how to check that?

I’ve read the forum most of the advice come to this article. Honestly I do not understand how could I apply this.

I’ll be very appreciated for any help where to look and what to do.

1 Like

Please provide any logs and sample code for the community to review

Honestly not too much of the code in here I probably do not understand in conception general.

On the page:
{{$auth.user.roles}} - returns empty string no worning no misstakes

In the component:
I use this lesson
The only place in the code which looks like the request is

    let webAuth = new auth0.WebAuth({
      domain: '',
      clientID: 'AHS6j7tx5Jby4L24p0OoFq95j2XCDb0t',
      // make sure this line is contains the port: 8080
      redirectUri: 'http://localhost:8080/callback',
      // we will use the api/v2/ to access the user information as payload
      audience: '', 
      responseType: 'token id_token',
      scope: 'openid profile roles',
      roles: 'pl'     // **so i've add this for the test**

The role is:

function (user, context, callback) {
  user.app_metadata = user.app_metadata || {};
  var addRolesToUser = function(user, cb) {
    if (context.roles === 'pl') {
      cb(null, ['plasterer']);
    } else {
      cb(null, ['user']);
  addRolesToUser(user, function(err, roles) {
    if (err) {
    } else {
      user.roles = user.app_metadata.roles; //**was added by the advice on this forum to avoide error when user doesn't exist**
      user.app_metadata.roles = roles;
      auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
          context.idToken[''] = user.app_metadata.roles; //**was in the tamplate have know idea what it does**
          callback(null, user, context); //**was in the tamplate have know idea what it does**
  callback(null, user, context);

Hey there!

Sorry for such huge 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 comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?