MCPcopy Index your code
hub / github.com/coder/coder / promptFirstPassword

Function promptFirstPassword

cli/login.go:76–101  ·  view source on GitHub ↗
(inv *serpent.Invocation)

Source from the content-addressed store, hash-verified

74}
75
76func promptFirstPassword(inv *serpent.Invocation) (string, error) {
77retry:
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
103func (r *RootCmd) loginWithPassword(
104 inv *serpent.Invocation,

Callers 1

loginMethod · 0.85

Calls 2

PromptFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected