Problem after assigning the default role within rules with the login after

Hi everyone

I have the problem that after assigning a default role within rules after the first login, the user doesn’t get logged in right away (the page goes blank and i need to close the browser and log in again to make it work). Several people had this problem before and i found this solution in a post:
renewToken() {
this.auth0Client$.subscribe((client: Auth0Client) => {
client.getTokenSilently({ audience: config.audience, scope: config.domain, ignoreCache: true });
});
}
But i don’t get it where to apply this? Or is there a solution where i can apply this directly in the rule where i assigned the default role?

Thanks for your help.

I tried it with another solution i found in a post and created this rule:

function (user, context, callback) {
  
  var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
  if (count > 1) {
    return callback(null, user, context);
  }
  
  var ManagementClient = require('auth0@2.17.0').ManagementClient;
  var management = new ManagementClient({
    token: auth0.accessToken,
    domain: auth0.domain
   
  });

  management.assignRolestoUser(
    { id : user.user_id}, 
    { "roles" :["rol_aDaX1wUBincYGcBE"]},  // sample role ID of "Standard API Enduser"
    function (err) {
      if (err) {
        console.log('Error assigning role: ' + err);
      }    
      callback(null, user, context);
  });
  let assignedRoles = (context.authorization || {}).roles;
  assignedRoles.push('rol_aDaX1wUBincYGcBE');
}

The assigning of the role seems to be working and the website gets loaded (so i have no more blank sceen after login) but the website doesn’t get fully loaded, like it shows the layout of the page but no content. Can any body help me with that? Do i need to add an extra step?
Thanks everyone for helping me!

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!