fix: route password rotation through the typed apiService contract - #400
Merged
Kingvic300 merged 1 commit intoAug 17, 2026
Merged
Conversation
SecurityTab rotated passwords via a duplicate axios client
(src/lib/api.ts) that posted a payload the deployed backend rejects,
while the typed apiService.updatePassword contract had zero callers.
Route the form through apiService.updatePassword, which now sends
{ email, current_password, new_password }: the deployed
/auth/update-password handler requires "email" (older contract) and
the backend repo's current handler requires "current_password", so
sending both works against the deployed instance today and survives
the backend upgrade. Delete the duplicate client.
Add request-body assertions in api.test.ts and SecurityTab tests
covering the submitted arguments and client-side validation.
Closes Txio-labs#382
|
@Shadow-MMN is attempting to deploy a commit to the oladimejivictor611-5012's projects Team on Vercel. A member of the Team first needs to authorize it. |
6 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
Password rotation had two incompatible client implementations for one backend route, and the one actually wired to the "Rotate Password" button sent a payload the deployed backend rejects. This consolidates everything onto the typed
apiService.updatePasswordcontract, corrects its payload shape to match the deployed backend, and adds test coverage asserting the exact request body.Root cause
SecurityTab.tsxsubmitted rotation through a standalone axios client (src/lib/api.ts) posting{ current_password, new_password, confirm_password }— noemail.apiService.updatePassword(email, newPassword)insrc/services/api.tsposted{ email, new_password }— and had zero callers anywhere insrc/.txio-oyac.onrender.com,/auth/update-passwordrejects a body withoutemail(HTTP 422missing field email). (The backend repo'smainbranch has since moved to a claims-based handler requiringcurrent_passwordinstead — the deployed instance is running the older contract.)Changes
src/services/api.ts—updatePassword(email, currentPassword, newPassword)now POSTs{ email, current_password, new_password }. Sending both fields works against the deployed instance today (it usesemail, ignores the rest) and survives the backend upgrade to the claims-based handler (which usescurrent_password, ignoresemail).src/components/AuthModal/tabs/SecurityTab.tsx— the Rotate Password form now callsapiService.updatePassword(user.email, currentPassword, newPassword). Error handling switched from axios'serror.response?.data?.messagetoApiError.message(which surfaces the backend's message).src/lib/api.ts— deleted. Its only consumer wasSecurityTab; the duplicate axios client and its deadupdatePasswordexport are gone.src/services/api.test.ts— new test asserting the exact request body ({ email, current_password, new_password }) and URL for/auth/update-password.src/components/AuthModal/tabs/SecurityTab.test.tsx— removed the deadlib/apimock; added tests asserting the form callsupdatePasswordwith the signed-in email + passwords, and that invalid forms (mismatched confirmation) never submit.Verification
npm test— 112 tests pass (17 files)npm run lint— 0 errorstsc --noEmit— no errors in changed files (pre-existing errors only in untouchedsrc/wallet/*.test.ts)getSessions/revokeSessionunchanged)Acceptance criteria
/auth/update-passwordhandler expectsupdatePassword/ duplicate axios client remainsNotes
emailin the body (legacy contract). When the backend deploys the claims-based handler fromtxio-backendmain,emailcan be dropped from this payload in a one-line change —current_passwordis already being sent, so nothing breaks in between.SecurityTab's submit path and the shared API client.Closes #382.