[PR #4769] [MERGED] fix(organization): pass ctx to DB hooks #13819

Closed
opened 2026-04-13 09:10:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4769
Author: @ping-maxwell
Created: 9/19/2025
Status: Merged
Merged: 9/19/2025
Merged by: @himself65

Base: canaryHead: fix/org-pass-ctx-to-hooks


📝 Commits (1)

  • bea5b8e fix(organization): pass ctx to DB hooks

📊 Changes

5 files changed (+22 additions, -7 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/adapter.ts (+9 -2)
📝 packages/better-auth/src/plugins/organization/routes/crud-invites.ts (+2 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.ts (+2 -2)
📝 packages/better-auth/src/plugins/organization/routes/crud-org.ts (+7 -3)
📝 packages/better-auth/src/plugins/organization/routes/crud-team.ts (+2 -0)

📄 Description

closes https://github.com/better-auth/better-auth/issues/4767


Summary by cubic

Pass the request context (ctx) to session updates in the organization plugin so DB hooks run with the correct context. Fixes missing context in setActiveOrganization/setActiveTeam flows and closes better-auth/better-auth#4767.

  • Bug Fixes
    • Adapter: setActiveOrganization and setActiveTeam now accept ctx and pass it to internalAdapter.updateSession.
    • Routes: All call sites updated to forward ctx (create/delete org, set active org/team, invitations, member removal/leave).
    • Ensures DB hooks receive tenant/audit context and execute as expected.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4769 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 9/19/2025 **Status:** ✅ Merged **Merged:** 9/19/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/org-pass-ctx-to-hooks` --- ### 📝 Commits (1) - [`bea5b8e`](https://github.com/better-auth/better-auth/commit/bea5b8e76ef19769fe6f15ac6646e2a6e7c99abd) fix(organization): pass `ctx` to DB hooks ### 📊 Changes **5 files changed** (+22 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+9 -2) 📝 `packages/better-auth/src/plugins/organization/routes/crud-invites.ts` (+2 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.ts` (+2 -2) 📝 `packages/better-auth/src/plugins/organization/routes/crud-org.ts` (+7 -3) 📝 `packages/better-auth/src/plugins/organization/routes/crud-team.ts` (+2 -0) </details> ### 📄 Description closes https://github.com/better-auth/better-auth/issues/4767 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Pass the request context (ctx) to session updates in the organization plugin so DB hooks run with the correct context. Fixes missing context in setActiveOrganization/setActiveTeam flows and closes better-auth/better-auth#4767. - **Bug Fixes** - Adapter: setActiveOrganization and setActiveTeam now accept ctx and pass it to internalAdapter.updateSession. - Routes: All call sites updated to forward ctx (create/delete org, set active org/team, invitations, member removal/leave). - Ensures DB hooks receive tenant/audit context and execute as expected. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:10:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#13819