Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TOTP from clipboard with existing content #78

Merged
merged 1 commit into from
Jul 4, 2022

Conversation

cquintana92
Copy link
Collaborator

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:

  1. Add a reset() call before filling the number from the clipboard, which clears the user-entered numbers.
  2. Add a small 100ms delay after the reset call, so the UI can be updated accordingly (after manual testing, without that delay the user won't even percieve it.
  3. Add a boolean flag to the 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

@ntnhon ntnhon added the bug Something isn't working label Jul 4, 2022
@ntnhon ntnhon merged commit e7352a9 into master Jul 4, 2022
@ntnhon ntnhon deleted the fix/totp-from-clipboard-with-existing-content branch July 4, 2022 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visual bug(?) allowing me to log in with "incorrect" TOTP code
2 participants