Skip to content

Commit

Permalink
refactor: user resp.Status in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
duaraghav8 committed Oct 20, 2019
1 parent be569ef commit f953a7a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions command/assign_user_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *AssignUserGroupsCommand) Run(args []string) int {
select {
case u := <-getUserCh:
if u.Err != nil {
c.Logger.Printf("Failed to resolve u ID: %v\n", err)
c.Logger.Printf("Failed to resolve user ID: %v\n", err)
return 1
}
user = u.User
Expand All @@ -108,7 +108,7 @@ func (c *AssignUserGroupsCommand) Run(args []string) int {
return 1
}
if g.Resp.StatusCode != http.StatusOK {
c.Logger.Printf("Failed to fetch list of groups: %v\n", g.Resp)
c.Logger.Printf("Failed to fetch list of groups: %s\n", g.Resp.Status)
return 1
}
groups = g.Groups
Expand Down
7 changes: 6 additions & 1 deletion command/create_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package command
import (
"github.com/okta/okta-sdk-golang/okta"
"github.com/okta/okta-sdk-golang/okta/query"
"net/http"
)

type CreateUserCommand struct {
Expand Down Expand Up @@ -83,11 +84,15 @@ func (c *CreateUserCommand) Run(args []string) int {
"firstName": cfg.FirstName,
"lastName": cfg.LastName,
}
user, _, err := client.User.CreateUser(okta.User{Profile: &profile}, queries)
user, resp, err := client.User.CreateUser(okta.User{Profile: &profile}, queries)
if err != nil {
c.Logger.Printf("Failed to create user: %v\n", err)
return 1
}
if resp.StatusCode != http.StatusOK {
c.Logger.Printf("Failed to create user: %s\n", resp.Status)
return 1
}

c.Logger.Printf("ID: %s\n", user.Id)
return 0
Expand Down
2 changes: 1 addition & 1 deletion command/deactivate_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *DeactivateUserCommand) Run(args []string) int {
return 1
}
if resp.StatusCode != http.StatusOK {
c.Logger.Printf("Failed to deactivate member: %v\n", resp)
c.Logger.Printf("Failed to deactivate member: %s\n", resp.Status)
return 1
}

Expand Down
2 changes: 1 addition & 1 deletion command/reset_user_multifactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c *ResetUserMultifactorsCommand) Run(args []string) int {
return 1
}
if resp.StatusCode != http.StatusOK {
c.Logger.Printf("Failed to reset member's multifactors: %v\n", resp)
c.Logger.Printf("Failed to reset member's multifactors: %s\n", resp.Status)
return 1
}

Expand Down
2 changes: 1 addition & 1 deletion command/reset_user_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *ResetUserPasswordCommand) Run(args []string) int {
return 1
}
if resp.StatusCode != http.StatusOK {
c.Logger.Printf("Failed to reset member's password: %v\n", resp)
c.Logger.Printf("Failed to reset member's password: %s\n", resp.Status)
return 1
}

Expand Down

0 comments on commit f953a7a

Please sign in to comment.