Okey. I’m fine with the hack if I understand why it works. I’ve adjust the code now to throw an error instead since I guess that was what was going on when trying to call an undefined object. So after I have updated the role of the user I throw an error and it seems to work. Is this because the actions retry a couple of time and in the next attempt the role has been assign?
Roles and RBAC permissions is part of the first login with the code below:
if (roleIdsToAssign.length > 0) {
await Promise.all([
client.assignRolestoUser(
{ id: event.user.user_id },
{ roles: roleIdsToAssign },
),
client.updateAppMetadata(
{ id: event.user.user_id },
{
...event.user.app_metadata,
roles_to_migrate: null,
migrate_roles: null,
},
),
]);
throw('retry');
}
As previously with the api object, without throw('retry');
the roles and permissions are not present.