Skip to content

fix: accepting a redundant invite to an organization the user already belongs to errors out#1742

Open
giladresisi wants to merge 1 commit into
mainfrom
fix/invite-already-member
Open

fix: accepting a redundant invite to an organization the user already belongs to errors out#1742
giladresisi wants to merge 1 commit into
mainfrom
fix/invite-already-member

Conversation

@giladresisi

Copy link
Copy Markdown
Collaborator

Why

When a user who is already a member of an organization clicks another still-valid invite link, addUserToOrg only dedupes on the invite id ("has this specific invite already been redeemed?") and never checks membership. The membership create then hits the userId_organizationId unique constraint and the request fails with an uncaught error.

Two pre-existing flows trigger it, both involving two separate invites for the same user and ending in that same uncaught error:

  1. The second invite is sent before the user joins via the first one, and clicked after they joined.
  2. The second invite is sent (e.g. resent by the org owner, who gets no already-a-member indication) after the user has already joined, and then clicked.

Membership data stays correct either way — the unique index blocks the duplicate — the bug is the uncaught error instead of a graceful no-op.

What changed

addUserToOrg now checks for an existing userOrganization row for that user + organization before creating one, and returns false — the same value it already returns for a redeemed invite, which the join flow handles as a clean no-op (the user just lands back in the app).

🤖 Generated with Claude Code

… belongs to no longer errors

addUserToOrg only deduped on the invite id, never on membership, so a
user who was already a member of the organization and clicked another
still-valid invite link hit the userId_organizationId unique constraint
and the request failed with an uncaught error. Two pre-existing flows
trigger it, both involving two separate invites for the same user and
ending in that same uncaught error: (1) the second invite is sent
before the user joins via the first, and clicked after; (2) the second
invite is sent after the user has already joined, and then clicked.
Check membership first and return false, the same value joinOrg already
handles as a clean no-op.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Jul 19, 2026
@postiz-contribution

Copy link
Copy Markdown

Contribution-checker quality warning
Heuristic score: 22/100 (low). This is a non-blocking warning surfaced by the project's quality settings.

Heuristics that flagged:

  • Excessive inline code references: 5 inline refs (>3)
  • PR doesn't use the repo's PR template: 5 required checkbox items missing (max 1, match ≥80%)
  • Body adds too many extra headers beyond the template: 2 extra headers (>1)
  • AI watermark phrase: Matched: "Generated with Claude Code"
  • Commit message too long: Longest: 809 chars

If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it.

@postiz-agent

postiz-agent Bot commented Jul 19, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant