Skip to content

Commit

Permalink
fix cwapi bug with new sling usage (#157)
Browse files Browse the repository at this point in the history
* fix sling usage

Co-authored-by: AlteredCoder <AlteredCoder>
  • Loading branch information
AlteredCoder committed Jul 29, 2020
1 parent 89c8d1a commit 5e561e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pkg/cwapi/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (ctx *ApiCtx) Signin() error {
}
jsonResp := &ApiResp{}

resp, err := ctx.Http.Post(ctx.SigninPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
resp, err := ctx.Http.New().Post(ctx.SigninPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
if err != nil {
return fmt.Errorf("api signin: HTTP request creation failed: %s", err)
}
Expand All @@ -155,6 +155,7 @@ func (ctx *ApiCtx) Signin() error {
}

ctx.Http = ctx.Http.Set("Authorization", jsonResp.Message)

log.Printf("api signin: signed in successfuly")
return nil
}
Expand All @@ -164,7 +165,7 @@ func (ctx *ApiCtx) RegisterMachine(machineID string, password string) error {
ctx.Creds.Password = password
jsonResp := &ApiResp{}

resp, err := ctx.Http.Post(ctx.RegisterPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
resp, err := ctx.Http.New().Post(ctx.RegisterPath).BodyJSON(ctx.Creds).ReceiveSuccess(jsonResp)
if err != nil {
return fmt.Errorf("api register machine: HTTP request creation failed: %s", err)
}
Expand All @@ -185,7 +186,7 @@ func (ctx *ApiCtx) ResetPassword(machineID string, password string) error {
jsonResp := &ApiResp{}

data := map[string]string{"machine_id": ctx.Creds.User, "password": ctx.Creds.Password}
resp, err := ctx.Http.Post(ctx.ResetPwdPath).BodyJSON(data).ReceiveSuccess(jsonResp)
resp, err := ctx.Http.New().Post(ctx.ResetPwdPath).BodyJSON(data).ReceiveSuccess(jsonResp)
if err != nil {
return fmt.Errorf("api reset password: HTTP request creation failed: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cwapi/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func (ctx *ApiCtx) Enroll(userID string) error {
toPush := map[string]string{"user_id": userID}
jsonResp := &ApiResp{}

resp, err := ctx.Http.Post(ctx.EnrollPath).BodyJSON(&toPush).ReceiveSuccess(jsonResp)
resp, err := ctx.Http.New().Post(ctx.EnrollPath).BodyJSON(&toPush).ReceiveSuccess(jsonResp)
if err != nil {
return fmt.Errorf("api enroll: HTTP request creation failed: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cwapi/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func (ctx *ApiCtx) PullTop() ([]map[string]string, error) {
top := &PullResp{}
resp, err := ctx.Http.Get(ctx.PullPath).ReceiveSuccess(top)
resp, err := ctx.Http.New().Get(ctx.PullPath).ReceiveSuccess(top)
if err != nil {
return nil, fmt.Errorf("api pull: HTTP request creation failed: %s", err)
}
Expand Down

0 comments on commit 5e561e3

Please sign in to comment.