コード例 #1
0
ファイル: auth.go プロジェクト: Kazanz/deis
// Login to a Deis controller.
func Login(controller string, username string, password string, sslVerify bool) error {
	u, err := url.Parse(controller)

	if err != nil {
		return err
	}

	controllerURL, err := chooseScheme(*u)

	if err != nil {
		return err
	}

	if err = client.CheckConection(client.CreateHTTPClient(sslVerify), controllerURL); err != nil {
		return err
	}

	if username == "" {
		fmt.Print("username: "******"" {
		fmt.Print("password: ")
		password, err = readPassword()
		fmt.Println()

		if err != nil {
			return err
		}
	}

	return client.Login(controllerURL, username, password, sslVerify)
}
コード例 #2
0
ファイル: auth.go プロジェクト: Kazanz/deis
// Register creates a account on a Deis controller.
func Register(controller string, username string, password string, email string,
	sslVerify bool) error {

	u, err := url.Parse(controller)

	if err != nil {
		return err
	}

	controllerURL, err := chooseScheme(*u)

	if err != nil {
		return err
	}

	if err = client.CheckConection(client.CreateHTTPClient(sslVerify), controllerURL); err != nil {
		return err
	}

	if username == "" {
		fmt.Print("username: "******"" {
		fmt.Print("password: "******"\npassword (confirm): ")
		passwordConfirm, err := readPassword()
		fmt.Println()

		if err != nil {
			return err
		}

		if password != passwordConfirm {
			return errors.New("Password mismatch, aborting registration.")
		}
	}

	if email == "" {
		fmt.Print("email: ")
		fmt.Scanln(&email)
	}

	return client.Register(controllerURL, username, password, email, sslVerify, true)
}
コード例 #3
0
ファイル: auth.go プロジェクト: laurrentt/deis
// Login to a Deis controller.
func Login(controller string, username string, password string, sslVerify bool) error {
	u, err := url.Parse(controller)

	if err != nil {
		return err
	}

	controllerURL, err := chooseScheme(*u)
	httpClient := client.CreateHTTPClient(sslVerify)

	if err != nil {
		return err
	}

	if err = client.CheckConection(httpClient, controllerURL); err != nil {
		return err
	}

	if username == "" {
		fmt.Print("username: "******"" {
		fmt.Print("password: ")
		password, err = readPassword()
		fmt.Println()

		if err != nil {
			return err
		}
	}

	c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}

	return doLogin(c, username, password)
}
コード例 #4
0
ファイル: auth.go プロジェクト: laurrentt/deis
// Register creates a account on a Deis controller.
func Register(controller string, username string, password string, email string,
	sslVerify bool) error {

	u, err := url.Parse(controller)
	httpClient := client.CreateHTTPClient(sslVerify)

	if err != nil {
		return err
	}

	controllerURL, err := chooseScheme(*u)

	if err != nil {
		return err
	}

	if err = client.CheckConection(httpClient, controllerURL); err != nil {
		return err
	}

	if username == "" {
		fmt.Print("username: "******"" {
		fmt.Print("password: "******"\npassword (confirm): ")
		passwordConfirm, err := readPassword()
		fmt.Println()

		if err != nil {
			return err
		}

		if password != passwordConfirm {
			return errors.New("Password mismatch, aborting registration.")
		}
	}

	if email == "" {
		fmt.Print("email: ")
		fmt.Scanln(&email)
	}

	c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}

	tempClient, err := client.New()

	if err == nil {
		c.Token = tempClient.Token
	}

	err = auth.Register(c, username, password, email)

	c.Token = ""

	if err != nil {
		return err
	}

	fmt.Printf("Registered %s\n", username)
	return doLogin(c, username, password)
}