feat(auth): Add field-level error handling and improved error parsing#95
Merged
Merged
Conversation
ayshadogo
approved these changes
Jun 23, 2026
ayshadogo
left a comment
Contributor
There was a problem hiding this comment.
Thank you for your effort boss
5 tasks
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
Correctly parses and displays all backend authentication error responses in the UI. Errors are mapped to user-friendly messages, shown in context (inline field errors or general alert), and automatically cleared when the user starts typing.
closes #61
Changes
src/features/auth/authThunks.jsparseAuthErrorhelper that maps backend error codes to structured{ message, field? }objectsEMAIL_NOT_VERIFIED,INVALID_CREDENTIALS,EMAIL_TAKEN,USER_NOT_FOUND,INVALID_TOKEN,TOKEN_EXPIREDregisterUserandloginUsernow callrejectWithValue(parseAuthError(err))instead of passing the raw errorsrc/features/auth/authSlice.jsfieldErrors: {}to initial state for field-specific backend errorssetAuthErrorto accept both plain strings and{ message, field? }objectsclearAuthErroraction to reset botherrorandfieldErrorsregisterUser.rejectedandloginUser.rejectednow populatefieldErrorswhen the error targets a specific field, otherwise populate generalerrorsrc/features/auth/authSelectors.jsselectAuthFieldErrorsselectorsrc/pages/Login.jsxerror/loadingstate withuseSelector(selectAuthError)/useSelector(selectAuthLoading)role="alert"for accessibilityclearAuthErroron changeclearAuthErroron unmount to prevent stale errors bleeding into other pagesloginUser.fulfilled.match(result)instead of checkingresult.payload(which was truthy even on error)src/pages/Register.jsxselectAuthErrorandselectAuthFieldErrorsfrom ReduxfieldErrors.email(e.g.EMAIL_TAKEN) renders inline below the email field, falling back to yup validation errorhandleFieldChangewrapper clears Redux errors on any field interactionclearAuthErroron unmounthandleCreateusesregisterUser.fulfilled.match(result)pattern, removed staletry/catchError Display Behavior
INVALID_CREDENTIALSEMAIL_NOT_VERIFIEDEMAIL_TAKENUSER_NOT_FOUNDINVALID_TOKEN/TOKEN_EXPIRED