Persist last active organization

I want to save the last active organization to automatically apply it to a new user session. I got the second part, but I'm unsure on how to save it in my database.

I've tried the following,
    hooks: {
        after: createAuthMiddleware(async (ctx) => {
            // ctx.context.session is null
            if (ctx.path === '/organization/set-active') {
                const organizationId = ctx.context?.returned?.id;
                if (organizationId) {
                    // TODO update database
                }
            }
        })
    }

but I don't know how to get the userId
Solution
GitHub
Is this suited for github? Yes, this is suited for github To Reproduce Use the auth config from below. Call setActive from the organization plugin Current vs. Expected behavior I expect to somewher...
Was this page helpful?