Anonymous - 3 days ago

Originally posted by: dominykas-aai-labs

1. Expired tokens are revived, but a pending user with no token is left locked out

Two near-identical situations get opposite treatment, and both are pinned as intended:

  • test_expired_invite_is_revived_by_a_later_add — a link that died three days ago goes live again, so the fresh member isn't locked out.
  • test_adding_pending_user_without_a_token_issues_no_link — a pending user with no token gets nothing, and is locked out until an admin resends.

The route into the second case is ordinary: invite P to org A, remove them from A (which invalidates their token), later add them to org B. Membership is granted, no link exists, no email goes out, and the dialog tells the admin an invite wasn't needed.

refresh_unused_expiry_for_user_with_session (api/domains/auth/repository.py) filters on is_used == False only, which is what makes expired rows eligible for revival. Revival also means a link that expired weeks ago becomes valid again with nobody notified.

The AC decides neither case, so flagging rather than blocking — but it's worth being a conscious decision.

2. Dialog copy is wrong for a pending user

ui/src/features/organizations/components/add-member-dialog.tsx says:

They already have an account, so no new invite was sent.

For AC row 2 — someone who has never set a password — that's misleading. They can't sign in, and the admin gets no hint that "Resend invite" exists or that the person is holding an unclicked link. result.member.isPending is already in the payload (ui/src/features/organizations/schemas.ts), so the two cases can be worded apart.

This also matters because after "no new invite was sent", the natural admin move is Resend invite — which mints a replacement and kills the org A link, reproducing the original bug's user-visible outcome one click later.

3. Nobody tells the added user anything

A pending user added to a second org receives no email; their link silently gains 24 hours and they discover the org at login. An active user added to an org also receives nothing — that part matches AC row 3 and predates this branch. Already flagged in the commit body as a known consequence; raising it here so it gets its own ticket rather than being lost.