Hi @AbdurrahmanDundar and welcome to the Auth0 Community!
I’m spotting two callbacks in your rule and both are conditional–thus, it only happens on certain conditions. I suggest putting callbacks outside conditional sentences–a better context understanding is required to make sure but that’s probably why you get the rule effectively executed in the second login attempt.
Best regards,
Just to clarify as well, are you manually adding users, or are users signing up on your app themselves? Rules run after successful authentication, so I was wondering if the role is not being assigned because users are being added manually and have not logged in yet.
If you are manually adding users to a database connection, then you may want to use a Post User Registration Hook. This hook runs after users are created for a database connection (so it will not run after someone logs in with a social connection, but it will run if a user is manually created). Let me know if you’d like more details about how to set that up if that is the case!