fix: retry password-prompt if 2nd entry doesn't match the 1st (#203)

This commit is contained in:
Daniel Moran
2021-07-21 12:23:39 -04:00
committed by GitHub
parent 68cfff003a
commit a111d83b5a

View File

@ -87,6 +87,7 @@ func (t *terminalStdio) GetSecret(prompt string, minLen int) (password string, e
// GetPassword prompts the user for a secret twice, and inputs must match.
// Uses stdio.MinPasswordLen as the minimum input length
func (t *terminalStdio) GetPassword(prompt string) (string, error) {
for {
pass1, err := t.GetSecret(prompt, MinPasswordLen)
if err != nil {
return "", err
@ -99,7 +100,10 @@ func (t *terminalStdio) GetPassword(prompt string) (string, error) {
if pass1 == pass2 {
return pass1, nil
}
return "", t.Error("Passwords do not match")
if err := t.Error("Passwords do not match"); err != nil {
return "", err
}
}
}
// GetConfirm asks the user for a y/n answer to a prompt.