mirror of https://github.com/docker/docs.git
forbid login of a null-string username
With this patch, the client blocks this type login, no sending useless messages to daemon and registry. This saves lots of time. Signed-off-by: Liu Hua <sdu.liu@huawei.com>
This commit is contained in:
parent
6c6729ef5b
commit
755df347fb
|
@ -81,8 +81,9 @@ func (cli *DockerCli) configureAuth(flUser, flPassword, flEmail, serverAddress s
|
|||
if !ok {
|
||||
authconfig = types.AuthConfig{}
|
||||
}
|
||||
authconfig.Username = strings.TrimSpace(authconfig.Username)
|
||||
|
||||
if flUser == "" {
|
||||
if flUser = strings.TrimSpace(flUser); flUser == "" {
|
||||
cli.promptWithDefault("Username", authconfig.Username)
|
||||
flUser = readInput(cli.in, cli.out)
|
||||
flUser = strings.TrimSpace(flUser)
|
||||
|
@ -91,6 +92,10 @@ func (cli *DockerCli) configureAuth(flUser, flPassword, flEmail, serverAddress s
|
|||
}
|
||||
}
|
||||
|
||||
if flUser == "" {
|
||||
return authconfig, fmt.Errorf("Error: Non-null Username Required")
|
||||
}
|
||||
|
||||
if flPassword == "" {
|
||||
oldState, err := term.SaveState(cli.inFd)
|
||||
if err != nil {
|
||||
|
@ -104,7 +109,7 @@ func (cli *DockerCli) configureAuth(flUser, flPassword, flEmail, serverAddress s
|
|||
|
||||
term.RestoreTerminal(cli.inFd, oldState)
|
||||
if flPassword == "" {
|
||||
return authconfig, fmt.Errorf("Error : Password Required")
|
||||
return authconfig, fmt.Errorf("Error: Password Required")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue