Hi I’m encountering an issue where if a user signs in via google oauth they are not assigned a role but if they login via username-password they are assigned the role. I created a post user login action where they should be assigned the role after login. This only works when it’s a username-password authentication. Shouldn’t the code below apply to all authentications.
Unfortunately, the Post-User Registration Action flow only runs after a user is added to a Database or Passwordless Connection. (Reference: Post User Registration Flow)
Since Google is a Social Connection, we recommend using a Post-Login Action to add permissions to a Social Connection user.
For your convenience, I have updated your code snippet:
We are checking the condition if logins_count does not equal 1, because we want the script to execute only when logins_count does equal 1, indicating that the user has just signed up.
Take note that when a user completes the sign-up process, they are automatically logged in, which increments their logins_count by 1.
Circling back, could you please clarify if you are encountering any errors with your Action script or if the role is just not being updated?
And have you tried using the Actions built-in debugger to check if the code is being executed? You can add console.log statements to verify if the code is running as expected.