Skip to content

Commit

Permalink
Merge branch 'main' into release-0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
bote795 committed Jul 29, 2021
2 parents a9a8b3e + a90b0ff commit e95011f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions workspace/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ func ListRoles(workspaceId string, client *houston.Client, out io.Writer) error

// Update workspace user role
func UpdateRole(workspaceId, email, role string, client *houston.Client, out io.Writer) error {
req := houston.Request{
Query: houston.WorkspaceUserUpdateRequest,
Variables: map[string]interface{}{"workspaceUuid": workspaceId, "email": email, "role": role},
}
r, err := req.DoWithClient(client)

if err != nil {
return err
}
newRole := r.Data.WorkspaceUpdateUserRole
// get user you are updating to show role from before change
roles, err := getUserRole(workspaceId, email, client, out)

Expand All @@ -118,6 +108,17 @@ func UpdateRole(workspaceId, email, role string, client *houston.Client, out io.
return errors.New("The user you are trying to change is not part of this workspace")
}

req := houston.Request{
Query: houston.WorkspaceUserUpdateRequest,
Variables: map[string]interface{}{"workspaceUuid": workspaceId, "email": email, "role": role},
}
r, err := req.DoWithClient(client)

if err != nil {
return err
}
newRole := r.Data.WorkspaceUpdateUserRole

fmt.Fprintf(out, "Role has been changed from %s to %s for user %s", rb.Role, newRole, email)
return nil
}
Expand Down

0 comments on commit e95011f

Please sign in to comment.