Post-login default role not showing on first login

Hello, I’ve been trying to implement a default role that should be given to any user upon their first login. My current problem is that the role is indeed given during the registration, but it is not effective on the first login (post registration). Users have to sign out and log back in to see the privileges given by the role, in my case giving access to an application. A simple refresh of the page does not work.

My current setup to provide the role on sign-up is using an Action in the Log In flow along with an M2M application to perform the granting of the role, as many tutorials here mention. Here is the code in my action, which again succeed in giving the role to the users:

exports.onExecutePostLogin = async (event, api) => {

  // Check if the user has a role assigned
  if (event.authorization && event.authorization.roles && event.authorization.roles.length > 0) {
    return;
  }

  // Create management API client instance
  const ManagementClient = require("auth0").ManagementClient;

  const management = new ManagementClient({
    domain: event.secrets.domain,
    clientId: event.secrets.clientID,
    clientSecret: event.secrets.clientSecret,
  });

  const params =  { id : event.user.user_id };
  const data = { "roles" : ["rol_etsLc2TeAYn6NDrD"] };

  try {
    await management.users.assignRoles(params, data);
  } catch (e) {
    console.log(e);
  }

};

I’ve also tried the solution outlined in this post Post-login Action Not Assigning a Default Role on Login - Auth0 Community but it did no work in my case.

Does anyone know how I can make it so the users do not have to sign out/log back in for the default role to be properly taken into account?