瀏覽代碼

Remove leading spaces of username when login

When we run `docker login` we will be asked to input our username.

Prior to this PR, "userA" and " userA" will be considered as two
diferrent user, which is not right.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Hu Keping 10 年之前
父節點
當前提交
2687502ba4
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      api/client/commands.go

+ 1 - 0
api/client/commands.go

@@ -344,6 +344,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
 	if username == "" {
 	if username == "" {
 		promptDefault("Username", authconfig.Username)
 		promptDefault("Username", authconfig.Username)
 		username = readInput(cli.in, cli.out)
 		username = readInput(cli.in, cli.out)
+		username = strings.Trim(username, " ")
 		if username == "" {
 		if username == "" {
 			username = authconfig.Username
 			username = authconfig.Username
 		}
 		}