diff --git a/users.go b/users.go index d90b1dc..9ca4931 100644 --- a/users.go +++ b/users.go @@ -11,6 +11,7 @@ const ( userPath = "/auth/admin/realms/:realm/users" userCountPath = userPath + "/count" userIDPath = userPath + "/:id" + groupsPath = userIDPath + "/groups" resetPasswordPath = userIDPath + "/reset-password" sendVerifyEmailPath = userIDPath + "/send-verify-email" executeActionsEmailPath = userIDPath + "/execute-actions-email" @@ -52,6 +53,13 @@ func (c *Client) GetUser(accessToken string, realmName, userID string) (UserRepr return resp, err } +// GetGroupsOfUser get the groups of the user. +func (c *Client) GetGroupsOfUser(accessToken string, realmName, userID string) ([]GroupRepresentation, error) { + var resp = []GroupRepresentation{} + var err = c.get(accessToken, &resp, url.Path(groupsPath), url.Param("realm", realmName), url.Param("id", userID)) + return resp, err +} + // UpdateUser updates the user. func (c *Client) UpdateUser(accessToken string, realmName, userID string, user UserRepresentation) error { return c.put(accessToken, url.Path(userIDPath), url.Param("realm", realmName), url.Param("id", userID), body.JSON(user))