Skip to content

fix(profile): render associate-flow errors as an alert instead of raw JSON - #50

Merged
amrtgaber merged 1 commit into
mainfrom
fix/render-associate-error-on-profile
May 27, 2026
Merged

fix(profile): render associate-flow errors as an alert instead of raw JSON#50
amrtgaber merged 1 commit into
mainfrom
fix/render-associate-error-on-profile

Conversation

@amrtgaber

Copy link
Copy Markdown
Contributor

Summary

  • When linking a provider fails (most commonly oauth_account_already_linked from 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, then navigate({replace: true}) to scrub the params so a refresh doesn't re-trigger.
  • New src/lib/associate-errors.ts holds the per-provider copy. The steam/google callback pages (dev fetch path) were duplicating the same map; they now reuse the helper.
  • /profile route 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 in profile-page.test.tsx including 4 new: happy-path alert, generic fallback, dismiss, ignore-malformed-search).
  • pnpm lint — 0 errors, only pre-existing warnings.
  • pnpm build — typecheck + bundle clean.
  • Manual: with the companion API PR deployed, sign in, attempt to link a Steam ID already attached to another user → land back at /profile showing "This Steam account is already linked to another criticalbit account. Unlink it there first." with an X to dismiss.

… 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.
@netlify

netlify Bot commented May 27, 2026

Copy link
Copy Markdown

Deploy Preview for criticalbit-auth-web ready!

Name Link
🔨 Latest commit 72986bf
🔍 Latest deploy log https://app.netlify.com/projects/criticalbit-auth-web/deploys/6a17326dabbea9000846ca98
😎 Deploy Preview https://deploy-preview-50--criticalbit-auth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@amrtgaber
amrtgaber merged commit 447c44c into main May 27, 2026
6 checks passed
@amrtgaber
amrtgaber deleted the fix/render-associate-error-on-profile branch May 27, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant