how to extend session object before creation and attach activeOrg.
Tanstack Start
@Better Auth better auth doesnt include active org in session, so i try to manully do it like this:
//TODO: needs check, better-auth doesnt have specific api for active org to attack to the session session: { create: { before: async (session) => { const userMemberRecord = await db.query.member.findFirst({ where: eq(schema.member.userId, session.userId), });
let activeOrgId = null;
if (userMemberRecord) { activeOrgId = userMemberRecord.organizationId; }
but this approach has issue, when: multi tab is opened, it doesnt sync them. i need the activeOrgId to load and redirect on beforeLoad(ssr) function of tanstack start.