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
}
}
})
}
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
Organization set-active endpoint is missing session context · Issu...
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...
Jump to solution
3 Replies
daveycodez
daveycodez3mo ago
You could just use sessionStorage and do this client side
Jan
JanOP2mo ago
But this won't persist across longer duration or multiple devices Push
Solution
Jan
Jan2mo ago
GitHub
Organization set-active endpoint is missing session context · Issu...
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...

Did you find this page helpful?