Assigning roles not working on first login


As part of our Auth0 deployment we are assigning roles to users on first login which is working great using Rules and the Management API. The problem I’m facing right now is that the new roles don’t take effect until subsequent logins. Ideally we need the roles to become available during the first login.

Looking at this forum other people have tackled this by pushing roles directly into the context.authorization.roles array which, as far as I understand, should mean that the roles become available in the user’s auth flow immediately.

This doesn’t seem to be the case for us - we’re authenticating users into Moodle specifically and I can see the correct roles if I console.log(context.authorization.roles) and look at the debug log but a later Auth0 rule still denies my test user access to our Moodle app.

Any ideas as to what I could be missing here?

This is apparently working now - in cleaning up all our Rules and refactoring bits of them it seems to have started working so evidently it was probably my terrible code :slight_smile:

1 Like

Hi @itstawmu,

Welcome to the Auth0 Community!

I’m happy to hear that you were able to resolve this issue!

If you have any more questions or concerns, please feel free to reach out to us again!

Thank you.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.