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

Reuse password option prompts again on a wrong password #4380

Merged
merged 6 commits into from
Aug 13, 2024

Conversation

pawanjay176
Copy link
Member

Issue Addressed

Resolves #4364

Proposed Changes

Prompt the user to enter the password if the password is incorrect on using the reuse-password flag.
This is useful when importing multiple keystores for which there are more than 1 passwords.

cc @remyroy

@pawanjay176 pawanjay176 added the ready-for-review The code is ready for review label Jun 6, 2023
michaelsproul
michaelsproul previously approved these changes Jun 6, 2023
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, has anyone tested in manually?

@remyroy
Copy link
Contributor

remyroy commented Jun 7, 2023

I manually tested it and it worked for me.

@pawanjay176
Copy link
Member Author

Just changed a match statement to if in 95518f6

@pawanjay176
Copy link
Member Author

@chong-he Found a bunch of edge cases not properly handled. Need to fix those

@pawanjay176 pawanjay176 added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Jun 7, 2023
@remyroy
Copy link
Contributor

remyroy commented Sep 29, 2023

Is there any update on this PR? It would be nice to fix #4364

@chong-he
Copy link
Member

@remyroy

After some testing, it was found that the PR requires a fix. Consider a scenario we have 2 keystore files with passwordA, and 3 keystore files with passwordB

When we import the keys, it is all good for the first 2 keystore files. Then it will detect that the third keystore file has a different password, which it will prompt the user to input a new password. The problem is: the UX doesn't check if the password is correct or not, and will import the validator regardless (including the case when a user enters a wrong password) and show:
Successfully imported keystore
Successfully updated validator_definitions.yml.

It also wouldn’t show whether the password is correct or not.

It will then proceed to the fourth keystore, which it will now be able to detect the incorrect password and prompt again for the correct password.

I attach a screenshot for reference.

pass

Comment on lines 177 to 178
previous_password = Some(password.clone());
break Some(password);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current issue is that upon a reused password, after prompting the user to enter the password (line 177), it does not check whether the password is correct or not and proceed to the next keystore regardless. So I added a call to check_password_on_keystore to check the password.

Suggested change
previous_password = Some(password.clone());
break Some(password);
previous_password = Some(password.clone());
if check_password_on_keystore(&keystore, &password)? {
break Some(password);
}

The issue now is, because it becomes a nested if loop, the UX when the password is incorrect becomes:
Invalid password
at a first try, and then jumps to the beginning of the loop and display:

Invalid password
Reuse previous password.
Invalid password
Reused password incorrect. Retry!

and alternating that way until a correct password is entered. Do we have a better way for the UX? I try using a while loop but that's weird outcome too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bd035f9

Thanks for catching it and testing the fix CK :)

@pawanjay176 pawanjay176 added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jul 9, 2024
@pawanjay176
Copy link
Member Author

@remyroy Sorry for the delay, this one went under the radar.

Fixed the issues now.

@chong-he
Copy link
Member

chong-he commented Jul 9, 2024

I have tested the feature and can confirm that it is working

@chong-he chong-he added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Aug 12, 2024
@jimmygchen
Copy link
Member

@mergify queue

Copy link

mergify bot commented Aug 12, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 22ccdb6

@mergify mergify bot merged commit 22ccdb6 into sigp:unstable Aug 13, 2024
28 checks passed
AgeManning pushed a commit to AgeManning/lighthouse that referenced this pull request Sep 3, 2024
* Prompt for password if incorrect in import

* lint and fmt

* Use if instead of match

* Fix issue raised by @chong-he

* Merge branch 'unstable' into reuse-pw-break

* Remove unused function
chong-he pushed a commit to chong-he/lighthouse that referenced this pull request Nov 26, 2024
* Prompt for password if incorrect in import

* lint and fmt

* Use if instead of match

* Fix issue raised by @chong-he

* Merge branch 'unstable' into reuse-pw-break

* Remove unused function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants