From a90b0ff9eec1993fb66e52f6ece6d9b2742a4965 Mon Sep 17 00:00:00 2001 From: "Nicolas A. Botello Jr" Date: Thu, 29 Jul 2021 11:05:35 -0500 Subject: [PATCH] change the order in which requests are called (#429) --- workspace/user.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/workspace/user.go b/workspace/user.go index ba9831370..8ad54010f 100644 --- a/workspace/user.go +++ b/workspace/user.go @@ -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) @@ -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 }