CRASM-3710: Fix User Pending Bug - Dev/Staging#1503
Open
aloftus23 wants to merge 5 commits into
Open
Conversation
… assignment idempotent so duplicate role inserts return 200 instead of 500, allowing update_user to clear invite_pending. When register/approve reports already approved, complete org assignment and invite_pending cleanup instead of only showing the dialog. Refresh pending and member tables every 30s while the page is open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗣 Description
Fixes users staying in the pending registration queue after a successful approve, including when org assignment already exists in the DB or register/approve was already completed.
Backend: add_user_to_org_v2 is idempotent (returns existing role on duplicate; IntegrityError fallback).
Frontend (RegionUsers.tsx): “Already approved” path completes org + invite_pending cleanup; 30s refresh of pending/member tables (paused during dialogs / hidden tab).
💭 Motivation and context
Staging logs showed: register/approve succeeding, then POST /v2/organizations/{id}/users returning 500 (duplicate role_user_id_organization_id), so update_user with invite_pending: false never ran. The UI could also treat “already approved” as done and remove the row without clearing pending. Stale pending rows (roles: [] after Manage Users) made the frontend retry org add and hit that 500.
🧪 Testing
Created backend and frontend unit tests.
✅ Pre-approval checklist
bump_versionscript if this repository is versioned and the changes in this PR warrant a version bump.✅ Pre-merge checklist
✅ Post-merge checklist