Enforce Email Domain Restriction with Google Sign-In
https://www.better-auth.com/docs/concepts/hooks#example-enforce-email-domain-restriction
Is there an easy way to do the same as the example above, but when using Google as a social sign in? I use Google Workspace at my work and we have custom domains, so I want to be able to verify if we're logging in with a Google account from that workspace. I'd like to be able to change where I'm sending the user depending on their email.
I've tried many things, like throwing
As far as I can see there's no easy way to intercept/read data as you're trying to log in through a social provider, only when creating an account, through database hooks, but I would like to intercept any sign-in whatsoever.
Is there an easy way to do the same as the example above, but when using Google as a social sign in? I use Google Workspace at my work and we have custom domains, so I want to be able to verify if we're logging in with a Google account from that workspace. I'd like to be able to change where I'm sending the user depending on their email.
I've tried many things, like throwing
APIError inside of mapProfileToUser or getUserInfo, but it doesn't trigger a redirection to /api/auth/error, which I could have short-circuited to maybe do what I want, but it didn't work out.As far as I can see there's no easy way to intercept/read data as you're trying to log in through a social provider, only when creating an account, through database hooks, but I would like to intercept any sign-in whatsoever.