Fix TOTP from clipboard with existing content #78
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.
Fixes: #74
If the user clicked on the "Fill from clipboard" button, the previously existing input was not cleared, which made the app show the first N digits the user had entered, and the first (6-N) digits from the clipboard code.
The function that adds a number to the code has a check that, whenever the entered code reaches 6 numbers, it will launch a
verify
call.However, the function that fills the code in the screen also performs a
verify
call (that means, two concurrent calls were sent at the same time), and when the first one fails (as it's using the wrong code), an error was displayed and the "wrong login attempt" e-mail was sent.But as the second
verify
call succeeded, as it was using the code from the clipboard, the app will be correctly logged in.The solution is the following:
reset()
call before filling the number from the clipboard, which clears the user-entered numbers.addNumber
function that allows us to control whether that function should perform the request (obtaining the text from the textviews) or not. In our case, as we have the code already available in the calling function (pasteAndVerify
), there's no need to perform that extra step.NOTE: As this project does not use Kotlin's coroutines, I've resorted to the old-known
Handler().postDelayed