Enforce Email Domain Restriction on Google
How can I achieve this? I tried doing the example from the documentation (https://www.better-auth.com/docs/concepts/hooks#example-enforce-email-domain-restriction) but that did not work for my case. I am trying to restrict for only a specific domain "example.com" to be accepted to sign up. 
Thank you!
Hooks | Better Auth
Better Auth Hooks let you customize BetterAuth's behavior
5 Replies
can you show how you do it atm?
and what do you mean by "did not work for my case"? explain what didin't work exactly
This is my code:
I created an after hook to check if it's a UCSC account, and a user was still able to create an account with Google. Google is the only Social Provider that I am using for this app. I also tried doing the 
before hook, but that still did not work. The if statement I used was 
use a database hook and check before it creates the user
https://www.better-auth.com/docs/concepts/database#1-before-hook
Database | Better Auth
Learn how to use a database with Better Auth.

@🌠kkMihai ⚡ Exactly what I needed!!! Worked perfectly! Thank you so much for your help!
happy to help