Set active organization in "after" hook?

Hi there!

Is it possible to set the user's active organization in an "after" hook? I.e.:

    hooks: {
      after: createAuthMiddleware(async (ctx) => {
        // get org id with custom logic here and set active org
      }),
    },


I've tried returned a modified newSession like this with no luck so far:

  return {
    context: {
      ...ctx,
      context: {
        ...ctx.context,
        newSession: {
          ...ctx.context.newSession,
          session: {
            ...ctx.context.newSession?.session,
            activeOrganizationId: // value here
          },
        },
      },
    },
  }
Was this page helpful?