Browse Source

Merge pull request #1515 from dotcloud/rework_auth_push

* Registry: Improve auth push
Guillaume J. Charmes 12 years ago
parent
commit
9cc3d7a18b
1 changed files with 5 additions and 16 deletions
  1. 5 16
      commands.go

+ 5 - 16
commands.go

@@ -857,10 +857,12 @@ func (cli *DockerCli) CmdPush(args ...string) error {
 	}
 
 	if err := push(); err != nil {
-		if err == fmt.Errorf("Authentication is required.") {
-			if err = cli.checkIfLogged("push"); err == nil {
-				return push()
+		if err.Error() == "Authentication is required." {
+			fmt.Fprintln(cli.out, "\nPlease login prior to push:")
+			if err := cli.CmdLogin(""); err != nil {
+				return err
 			}
+			return push()
 		}
 		return err
 	}
@@ -1512,19 +1514,6 @@ func (cli *DockerCli) CmdCp(args ...string) error {
 	return nil
 }
 
-func (cli *DockerCli) checkIfLogged(action string) error {
-	// If condition AND the login failed
-	if cli.configFile.Configs[auth.IndexServerAddress()].Username == "" {
-		if err := cli.CmdLogin(""); err != nil {
-			return err
-		}
-		if cli.configFile.Configs[auth.IndexServerAddress()].Username == "" {
-			return fmt.Errorf("Please login prior to %s. ('docker login')", action)
-		}
-	}
-	return nil
-}
-
 func (cli *DockerCli) call(method, path string, data interface{}) ([]byte, int, error) {
 	var params io.Reader
 	if data != nil {