| 74 | } |
| 75 | |
| 76 | func promptFirstPassword(inv *serpent.Invocation) (string, error) { |
| 77 | retry: |
| 78 | password, err := cliui.Prompt(inv, cliui.PromptOptions{ |
| 79 | Text: "Enter a " + pretty.Sprint(cliui.DefaultStyles.Field, "password") + ":", |
| 80 | Secret: true, |
| 81 | Validate: userpassword.Validate, |
| 82 | }) |
| 83 | if err != nil { |
| 84 | return "", xerrors.Errorf("specify password prompt: %w", err) |
| 85 | } |
| 86 | confirm, err := cliui.Prompt(inv, cliui.PromptOptions{ |
| 87 | Text: "Confirm " + pretty.Sprint(cliui.DefaultStyles.Field, "password") + ":", |
| 88 | Secret: true, |
| 89 | Validate: cliui.ValidateNotEmpty, |
| 90 | }) |
| 91 | if err != nil { |
| 92 | return "", xerrors.Errorf("confirm password prompt: %w", err) |
| 93 | } |
| 94 | |
| 95 | if confirm != password { |
| 96 | _, _ = fmt.Fprintln(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Error, "Passwords do not match")) |
| 97 | goto retry |
| 98 | } |
| 99 | |
| 100 | return password, nil |
| 101 | } |
| 102 | |
| 103 | func (r *RootCmd) loginWithPassword( |
| 104 | inv *serpent.Invocation, |