Repository navigation
fix: wallet disconnect fails silently — add DELETE /users/:id/stellar-address (#714) - #718
Merged
Merged
Conversation
…714) PATCH { stellarAddress: null } always returned 400 because the @IsStellarAddress() validator on SetStellarAddressDto only accepts a valid Stellar Ed25519 public key — null never passes StrKey validation. The disconnect() call on the frontend was silently swallowed by its .catch(() => {}) so the failure was invisible to users and maintainers. Adds a dedicated DELETE :id/stellar-address route that accepts no body and sets user.stellarAddress to null via a new clearStellarAddress() service method, keeping the PATCH route strictly typed for real addresses.
#714) Adds two spec blocks: - users.service.spec.ts: NotFoundException on missing user; null written to stellarAddress and persisted via userRepo.save. - users.controller.spec.ts: wires the clearStellarAddress mock; asserts the happy path returns stellarAddress: null and the cross-user attempt throws ForbiddenException without calling the service.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
This branch had an error being deployed
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
Closes #714
Root cause:
disconnect()on the frontend callsPATCH /users/:id/stellar-addresswith{ stellarAddress: null }. The@IsStellarAddress()validator onSetStellarAddressDtorunsStrKey.isValidEd25519PublicKey(null)which always returnsfalse, so the backend returns400 Bad Request. The.catch(() => {})indisconnect()swallowed the error completely, leavingAuthUser.stellarAddressset on the backend while the local UI appeared disconnected.Fix (backend — this PR):
DELETE /users/:id/stellar-address— a dedicated unlink route that accepts no body and setsstellarAddress = nullvia a newclearStellarAddress()service method.PATCH :id/stellar-addressstrictly typed for real StrKey-validated addresses; the two operations have distinct semantics and should not share a DTO.users.service.spec.ts(NotFoundException + null-write) andusers.controller.spec.ts(happy path + 403 cross-user rejection).Frontend fix is raised in a companion PR on the frontend repo — changes
disconnect()to callDELETEinstead ofPATCH { stellarAddress: null }and surfaces backend errors to the console instead of silently discarding them.Test plan
npm run test— newclearStellarAddressservice and controller specs passDELETE /users/:id/stellar-addressas the address owner → 200,stellarAddress: nullin responseDELETE /users/:id/stellar-addressas a different authenticated user → 403PATCH /users/:id/stellar-addresswith{ stellarAddress: null }still returns 400 (existing validator unchanged)