Jelajahi Sumber

Allow user to change email/passwd via login

Signed-off-by: Doug Davis <dug@us.ibm.com>
Doug Davis 10 tahun lalu
induk
melakukan
e315493b0c
1 mengubah file dengan 12 tambahan dan 2 penghapusan
  1. 12 2
      api/client/commands.go

+ 12 - 2
api/client/commands.go

@@ -273,6 +273,8 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
 			username = authconfig.Username
 			username = authconfig.Username
 		}
 		}
 	}
 	}
+	// Assume that a different username means they may not want to use
+	// the password or email from the config file, so prompt them
 	if username != authconfig.Username {
 	if username != authconfig.Username {
 		if password == "" {
 		if password == "" {
 			oldState, _ := term.SaveState(cli.terminalFd)
 			oldState, _ := term.SaveState(cli.terminalFd)
@@ -296,8 +298,16 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
 			}
 			}
 		}
 		}
 	} else {
 	} else {
-		password = authconfig.Password
-		email = authconfig.Email
+		// However, if they don't override the username use the
+		// password or email from the cmd line if specified. IOW, allow
+		// then to change/overide them.  And if not specified, just
+		// use what's in the config file
+		if password == "" {
+			password = authconfig.Password
+		}
+		if email == "" {
+			email = authconfig.Email
+		}
 	}
 	}
 	authconfig.Username = username
 	authconfig.Username = username
 	authconfig.Password = password
 	authconfig.Password = password