ENG-3370: Fix incorrect error message on login with bad credentials#7882
ENG-3370: Fix incorrect error message on login with bad credentials#7882gilluminate merged 3 commits intomainfrom
Conversation
The login error handler was surfacing raw backend error details (added in PR #6904), which on SSO-configured environments showed "Username and password login is disabled when SSO is configured" for any credential failure. Now only uses getErrorMessage for invite/reset-password flows where backend details are meaningful; standard login always shows the generic fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Code Review: Fix incorrect error message on login with bad credentials
The fix is correct and minimal. The logic inversion — from calling getErrorMessage() on all three branches with a fallback, to only calling it where backend error detail is actually useful — directly addresses the root cause without over-engineering. The security implication (preventing backend SSO config state from leaking through login error messages) is handled properly.
Suggestions
console.log(error) at line 172 (inline comment): This pre-existing line logs the raw RTK error object to the browser console, including status codes, response body, and potentially SSO configuration detail — exactly the class of information this PR is trying to prevent from leaking. Should be console.error at minimum, or removed for a production login page.
Comment asymmetry between branches (inline comment): The else branch gets a clear comment explaining why it avoids getErrorMessage(). The invite/reset-password branches have no corresponding comment explaining why they intentionally do call it. Adding a brief comment there would make the three-way asymmetry self-documenting and reduce the chance of a future contributor copying the wrong pattern.
Missing test coverage: There are no tests for login.tsx. The original regression (calling getErrorMessage() unconditionally) is exactly the kind of error that branch-level unit tests would catch. The three paths are now clearly defined, making them straightforward to test with mocked RTK mutations:
- Standard login failure → always returns the hardcoded string, regardless of
error.data.detail - Invite failure → passes error through
getErrorMessage() - Reset-password failure → passes error through
getErrorMessage()
Positive notes
- The rename from
defaultErrorMsgtoerrorMsgis correct — the old name was misleading since the variable held the final message, not a fallback. - The inline comment on the
elsebranch is good documentation of intent. - The changelog entry is accurate and well-scoped.
🔬 Codegraph: connected (42425 nodes)
💡 Write /code-review in a comment to re-run this review.
…7882) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ticket ENG-3370
Description Of Changes
On SSO-configured environments (like RC), entering incorrect credentials showed "Username and password login is disabled when SSO is configured. Please use SSO to login." instead of the expected generic login error.
Root cause: PR #6904 introduced
getErrorMessage()to the login catch block, which extractserror.data.detailfrom backend responses. The fidesplususer_login_extendedendpoint runs an SSO check before credential validation, and when credentials are wrong, the SSO guard can fire and return its error message. This backend detail was being surfaced to users instead of the generic login failure message.Fix: Only use
getErrorMessage()for the invite and reset-password flows where backend error details are meaningful to the user. The standard login flow always shows the generic "Login failed. Please check your credentials and try again." message, matching the original behavior and avoiding leaking backend configuration details.Code Changes
clients/admin-ui/src/pages/login.tsx- Modified thehandleSubmitcatch block to usegetErrorMessage()only for invite/reset-password flows, not for standard loginSteps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdated