[PR #6750] [CLOSED] feat/organization-plugin-allow-unverified-users-to-accept-inivitation #6864

Closed
opened 2026-03-13 13:14:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6750
Author: @Ridhim-RR
Created: 12/14/2025
Status: Closed

Base: canaryHead: feat/organization-plugin-allow-unverified-users-to-accept-inivitation


📝 Commits (2)

  • 041be5e feat/organization-plugin-allow-unverified-users-to-accept-inivitation
  • 3e63cfb Merge branch 'canary' into feat/organization-plugin-allow-unverified-users-to-accept-inivitation

📊 Changes

1 file changed (+76 additions, -31 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/routes/crud-invites.ts (+76 -31)

📄 Description

closes #6716

This PR enables the new Signup user to accept the invitation without any session.

Changes

  • Removed orgSessionMiddleware from the acceptInvitation flow so the session is now optional.
  • If a session exists, the user is taken from session.user (previous behavior).
  • If no session exists, the user is looked up by the invitation email, and the invitation email is verified to match the user’s email.
  • Email verification is enforced only when the user has an active session.
  • For new signups without a session, the email verification check is skipped, allowing them to accept the invitation first and verify their email later.

Files updated

  • crud-invites.ts: updated acceptInvitation implementation to support the new flow.

Summary by cubic

Allows new signups without a session or verified email to accept organization invitations. Session is now optional in the acceptInvitation flow, and email verification can happen later.

  • New Features
    • Removed orgSessionMiddleware from acceptInvitation.
    • If a session exists, verify the invitation email matches the session user; otherwise, find the user by the invitation email.
    • Enforce requireEmailVerificationOnInvitation only for users with an active session.
    • Create team memberships for invited users; skip function-based team limit checks without a session, but enforce numeric limits.
    • Set active team/organization and update cookies only when a session is present.
    • Pass the resolved user to before/afterAcceptInvitation hooks.

Written for commit 3e63cfb65c. Summary will update automatically on new commits.


🔄 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/6750 **Author:** [@Ridhim-RR](https://github.com/Ridhim-RR) **Created:** 12/14/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/organization-plugin-allow-unverified-users-to-accept-inivitation` --- ### 📝 Commits (2) - [`041be5e`](https://github.com/better-auth/better-auth/commit/041be5e874a2d8a18219fe894efa83a7f96ee0ed) feat/organization-plugin-allow-unverified-users-to-accept-inivitation - [`3e63cfb`](https://github.com/better-auth/better-auth/commit/3e63cfb65cc71941a24f50d78b3a7d27896a82a3) Merge branch 'canary' into feat/organization-plugin-allow-unverified-users-to-accept-inivitation ### 📊 Changes **1 file changed** (+76 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/routes/crud-invites.ts` (+76 -31) </details> ### 📄 Description closes #6716 This PR enables the new Signup user to accept the invitation without any session. **Changes** - Removed orgSessionMiddleware from the acceptInvitation flow so the session is now optional. - If a session exists, the user is taken from session.user (previous behavior). - If no session exists, the user is looked up by the invitation email, and the invitation email is verified to match the user’s email. - Email verification is enforced only when the user has an active session. - For new signups without a session, the email verification check is skipped, allowing them to accept the invitation first and verify their email later. **Files updated** - crud-invites.ts: updated acceptInvitation implementation to support the new flow. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allows new signups without a session or verified email to accept organization invitations. Session is now optional in the acceptInvitation flow, and email verification can happen later. - **New Features** - Removed orgSessionMiddleware from acceptInvitation. - If a session exists, verify the invitation email matches the session user; otherwise, find the user by the invitation email. - Enforce requireEmailVerificationOnInvitation only for users with an active session. - Create team memberships for invited users; skip function-based team limit checks without a session, but enforce numeric limits. - Set active team/organization and update cookies only when a session is present. - Pass the resolved user to before/afterAcceptInvitation hooks. <sup>Written for commit 3e63cfb65cc71941a24f50d78b3a7d27896a82a3. Summary will update automatically on new commits.</sup> <!-- 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-03-13 13:14:23 -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#6864