How to manage different role assingments in Google/Apple (etc.) login? #2365

Closed
opened 2026-03-13 09:47:25 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @yakupensarsayin on GitHub (Nov 22, 2025).

Is this suited for github?

  • Yes, this is suited for github

No response

Describe the solution you'd like

Hello. We manage SSO with Better Auth. As a business requirement, we want to assign the “x” role to the user when they register with Google on the web frontend, and assign the “y” role when they register with Google on our React Native mobile app. How can we manage this? Actually, my question is more about how role management can be done with a single Google login.

Describe alternatives you've considered

I looked into Better Auth hooks for research. I couldn't find much information. I thought I might need to send something like an intent to Google (or another SSO provider) and then capture it with a hook. What do you recommend?

Additional context

No response

Originally created by @yakupensarsayin on GitHub (Nov 22, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. _No response_ ### Describe the solution you'd like Hello. We manage SSO with Better Auth. As a business requirement, we want to assign the “x” role to the user when they register with Google on the web frontend, and assign the “y” role when they register with Google on our React Native mobile app. How can we manage this? Actually, _**my question is more about how role management can be done with a single Google login.**_ ### Describe alternatives you've considered I looked into Better Auth hooks for research. I couldn't find much information. I thought I might need to send something like an intent to Google (or another SSO provider) and then capture it with a hook. What do you recommend? ### Additional context _No response_
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 22, 2025):

Hello! You can handle this scenario by extending Better Auth’s post-registration hooks to customize role assignment based on the context of the login. One common approach is to pass an additional state parameter with your OAuth flow (e.g., a marker that indicates whether the login is from the web frontend or React Native). Then, in a post sign-up or user creation hook, you can inspect that parameter and assign the “x” role for web registration and “y” for mobile accordingly [1].

If you haven't yet implemented custom hooks in your Better Auth setup, I’d recommend reviewing how to add a post-auth hook that allows you to modify the user object after a successful social sign-in. This will let you programmatically update the user’s roles based on the provided metadata.

Have you already set up custom hooks in your configuration, or would you need more guidance on that?

tag @better-auth-agent if you would like an answer from the Agent

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Nov 22, 2025): Hello! You can handle this scenario by extending Better Auth’s post-registration hooks to customize role assignment based on the context of the login. One common approach is to pass an additional state parameter with your OAuth flow (e.g., a marker that indicates whether the login is from the web frontend or React Native). Then, in a post sign-up or user creation hook, you can inspect that parameter and assign the “x” role for web registration and “y” for mobile accordingly [[1]](https://www.better-auth.com/docs/reference/contributing). If you haven't yet implemented custom hooks in your Better Auth setup, I’d recommend reviewing how to add a post-auth hook that allows you to modify the user object after a successful social sign-in. This will let you programmatically update the user’s roles based on the provided metadata. Have you already set up custom hooks in your configuration, or would you need more guidance on that? tag @better-auth-agent if you would like an answer from the Agent <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2365