Browse Source

fix login

Victor Vieux 12 years ago
parent
commit
24c785bc06
2 changed files with 3 additions and 3 deletions
  1. 1 2
      api.go
  2. 2 1
      commands.go

+ 1 - 2
api.go

@@ -53,7 +53,6 @@ func getAuth(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error
 func postAuth(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
 	var config auth.AuthConfig
 	if err := json.NewDecoder(r.Body).Decode(&config); err != nil {
-		http.Error(w, err.Error(), http.StatusInternalServerError)
 		return nil, err
 	}
 
@@ -73,8 +72,8 @@ func postAuth(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, erro
 		b, err := json.Marshal(ApiAuth{status})
 		if err != nil {
 			return nil, err
-			return b, nil
 		}
+		return b, nil
 	}
 	w.WriteHeader(http.StatusOK)
 	return nil, nil

+ 2 - 1
commands.go

@@ -270,11 +270,12 @@ func CmdLogin(args ...string) error {
 	}
 
 	var out2 ApiAuth
-	err = json.Unmarshal(body, &out)
+	err = json.Unmarshal(body, &out2)
 	if err != nil {
 		return err
 	}
 	if out2.Status != "" {
+		RestoreTerminal(oldState)
 		fmt.Print(out2.Status)
 	}
 	return nil