mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: Add roles into the user response (#1347)
This commit is contained in:
+6
-5
@@ -45,6 +45,7 @@ type User struct {
|
||||
Username string `json:"username" validate:"required"`
|
||||
Status UserStatus `json:"status"`
|
||||
OrganizationIDs []uuid.UUID `json:"organization_ids"`
|
||||
Roles []Role `json:"roles"`
|
||||
}
|
||||
|
||||
type CreateFirstUserRequest struct {
|
||||
@@ -216,17 +217,17 @@ func (c *Client) UpdateUserRoles(ctx context.Context, userID uuid.UUID, req Upda
|
||||
|
||||
// UpdateOrganizationMemberRoles grants the userID the specified roles in an org.
|
||||
// Include ALL roles the user has.
|
||||
func (c *Client) UpdateOrganizationMemberRoles(ctx context.Context, organizationID, userID uuid.UUID, req UpdateRoles) (User, error) {
|
||||
func (c *Client) UpdateOrganizationMemberRoles(ctx context.Context, organizationID, userID uuid.UUID, req UpdateRoles) (OrganizationMember, error) {
|
||||
res, err := c.request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/organizations/%s/members/%s/roles", organizationID, uuidOrMe(userID)), req)
|
||||
if err != nil {
|
||||
return User{}, err
|
||||
return OrganizationMember{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return User{}, readBodyAsError(res)
|
||||
return OrganizationMember{}, readBodyAsError(res)
|
||||
}
|
||||
var user User
|
||||
return user, json.NewDecoder(res.Body).Decode(&user)
|
||||
var member OrganizationMember
|
||||
return member, json.NewDecoder(res.Body).Decode(&member)
|
||||
}
|
||||
|
||||
// GetUserRoles returns all roles the user has
|
||||
|
||||
Reference in New Issue
Block a user