have list of all organizations user is in in session object

how to do it?
4 Replies
nikatune
nikatune3mo ago
you can use hook
const { data: organizations } = authClient.useListOrganizations()
const { data: organizations } = authClient.useListOrganizations()
Ping
Ping3mo ago
We don't recommend putting all of the users orgs in the session. Like what nikatune said, using a hook would be better. If you really need to for whatever the reason may be, you can take a look at our custom session plugin
Session Management | Better Auth
Better Auth session management.
Adam Borygo
Adam BorygoOP3mo ago
i need to validate in the trpc middleware based on passed id and dont know if its better to store that in the session or check permissions on the middleware
Ping
Ping3mo ago
Yeah just make the nessesary DB requests based on the session info to check if they have permission to do whatever

Did you find this page helpful?