fix: retry password-prompt if 2nd entry doesn't match the 1st (#203)
This commit is contained in:
@ -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.
|
// GetPassword prompts the user for a secret twice, and inputs must match.
|
||||||
// Uses stdio.MinPasswordLen as the minimum input length
|
// Uses stdio.MinPasswordLen as the minimum input length
|
||||||
func (t *terminalStdio) GetPassword(prompt string) (string, error) {
|
func (t *terminalStdio) GetPassword(prompt string) (string, error) {
|
||||||
|
for {
|
||||||
pass1, err := t.GetSecret(prompt, MinPasswordLen)
|
pass1, err := t.GetSecret(prompt, MinPasswordLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -99,7 +100,10 @@ func (t *terminalStdio) GetPassword(prompt string) (string, error) {
|
|||||||
if pass1 == pass2 {
|
if pass1 == pass2 {
|
||||||
return pass1, nil
|
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.
|
// GetConfirm asks the user for a y/n answer to a prompt.
|
||||||
|
Reference in New Issue
Block a user