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
All good, I resolved my issue by using ctx.context.newSession and ctx.redirect