See what provider made the session

Is there a way to see what provider triggered the session creation? I need to restrict some stuff based on which provider you used to log on due to business restrictions. Or do you have any tips for a workaround.
4 Replies
Ping
Ping2d ago
You can use hooks to see which provider was called. https://www.better-auth.com/docs/concepts/hooks#after-hooks change the path to look for /callback/:id (I think that's correct, not certain, you might have to do some testing). Then you can get the provider from ctx.url and check for the part which would be the id part of the url (if that makes sense)
srd
srdOPthis hour
thanks, that solved it when i dont use session cache. i have tried different stuff, and it looks like there is no way to modify the session data in the before hook (to modify it before the cache kicks in)
No description
srd
srdOPthis hour
is the only option to temp save the info in a map for example to be able to get it in the db hook before session? i basically need it to automatically set the active org, but only when you log on using microsoft
Bruh
Bruh21h ago
Also wondering if there is a way to do this in the before hook to avoid the extra database call?

Did you find this page helpful?