예제 #1
0
파일: auth.go 프로젝트: Kazanz/deis
// Passwd changes a user's password.
func Passwd(username string, password string, newPassword string) error {
	client, err := New()

	if err != nil {
		return err
	}

	req := api.AuthPasswdRequest{Password: password, NewPassword: newPassword}

	if username != "" {
		req.Username = username
	}

	body, err := json.Marshal(req)

	if err != nil {
		return err
	}

	resBody, status, err := client.BasicRequest("POST", "/v1/auth/passwd/", body)

	if err != nil {
		return err
	}

	if status != 200 {
		return fmt.Errorf("Password change failed: %s", resBody)
	}

	fmt.Println("Password change succeeded.")
	return nil
}
예제 #2
0
파일: auth.go 프로젝트: laurrentt/deis
// Passwd changes a user's password.
func Passwd(c *client.Client, username, password, newPassword string) error {
	req := api.AuthPasswdRequest{Password: password, NewPassword: newPassword}

	if username != "" {
		req.Username = username
	}

	body, err := json.Marshal(req)

	if err != nil {
		return err
	}

	_, err = c.BasicRequest("POST", "/v1/auth/passwd/", body)
	return err
}