fix(profile): render associate-flow errors as an alert instead of raw JSON - #50
Merged
Merged
Conversation
… JSON
When linking a provider fails (most commonly oauth_account_already_linked),
the backend now 302s back to /profile?associate_error=<code>&associate_provider=<p>
instead of returning JSON. Render the result as a dismissible destructive
alert in the Connected accounts section, then scrub the URL via
navigate({replace: true}) so a refresh doesn't re-trigger.
- New src/lib/associate-errors.ts holds the per-provider copy (also used
by the dev fetch path in the steam/google callback pages, which were
duplicating the same map).
- profile route validates the pair atomically — if either param is
missing or the provider is unknown, both are dropped.
- Tests cover the happy path, generic fallback, dismiss action, and the
malformed-search guard.
✅ Deploy Preview for criticalbit-auth-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Summary
oauth_account_already_linkedfrom a Steam/Google ID already tied to another account), the backend now redirects to/profile?associate_error=<code>&associate_provider=<provider>instead of returning JSON. Render that as a dismissible destructive alert in the Connected accounts section, thennavigate({replace: true})to scrub the params so a refresh doesn't re-trigger.src/lib/associate-errors.tsholds the per-provider copy. The steam/google callback pages (dev fetch path) were duplicating the same map; they now reuse the helper./profileroute validates the pair atomically — drop both if either is missing or the provider is unknown, rather than half-rendering.Companion PR
Backend redirect that produces these URL params: ag-tech-group/criticalbit-auth-api#46 — should land together.
Test plan
pnpm test:run— 53 passed (20 inprofile-page.test.tsxincluding 4 new: happy-path alert, generic fallback, dismiss, ignore-malformed-search).pnpm lint— 0 errors, only pre-existing warnings.pnpm build— typecheck + bundle clean./profileshowing "This Steam account is already linked to another criticalbit account. Unlink it there first." with an X to dismiss.