How to access user email or userId in social login hook (Google/Microsoft)?
Hi everyone! 👋
I’m trying to handle user logins using Google and Microsoft in BetterAuth.
In the after hook of createAuthMiddleware, I want to check some conditions based on the user’s email or userId, like I already do for regular email sign-in (see screenshot).
However, during the /callback/:id route (social login), I’m not sure how to retrieve the email or userId of the user trying to log in. Is it possible to access that information in a before or after hook?
Any pointers or examples would be greatly appreciated 🙏
Thanks in advance!

Solution:
Jump to solution
All good, I resolved my issue by using ctx.context.newSession and ctx.redirect 👍

2 Replies