fix: patch secure email change (double confirm) response format. #1241
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.
What kind of change does this PR introduce?
There are two issues the PR aims to resolve:
Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in fix: clear email change token when token hash is used #1240 but a test was added in this branch.
Currently, the single confirmation response is slightly misformed and has an additional null param
This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to
sendJSON(w, http.StatusOK, token)
being run aftersendJSON
is callled which will write thetoken
(nil
in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error.What is the new behavior?
Returns response
Additional context
TODO