-
Notifications
You must be signed in to change notification settings - Fork 943
refactor: Add roles into the user response #1347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b27a5ed
b1bb55f
87c474b
a9c8def
6ff75cc
8588cf8
440308f
dda5809
27e14bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -15,7 +15,7 @@ func (*api) assignableSiteRoles(rw http.ResponseWriter, _ *http.Request) { | |||
// TODO: @emyrk in the future, allow granular subsets of roles to be returned based on the | ||||
// role of the user. | ||||
roles := rbac.SiteRoles() | ||||
httpapi.Write(rw, http.StatusOK, codersdk.ConvertRoles(roles)) | ||||
httpapi.Write(rw, http.StatusOK, ConvertRoles(roles)) | ||||
} | ||||
|
||||
// assignableSiteRoles returns all site wide roles that can be assigned. | ||||
|
@@ -24,5 +24,20 @@ func (*api) assignableOrgRoles(rw http.ResponseWriter, r *http.Request) { | |||
// role of the user. | ||||
organization := httpmw.OrganizationParam(r) | ||||
roles := rbac.OrganizationRoles(organization.ID) | ||||
httpapi.Write(rw, http.StatusOK, codersdk.ConvertRoles(roles)) | ||||
httpapi.Write(rw, http.StatusOK, ConvertRoles(roles)) | ||||
} | ||||
|
||||
func ConvertRole(role rbac.Role) codersdk.Role { | ||||
return codersdk.Role{ | ||||
DisplayName: role.DisplayName, | ||||
Name: role.Name, | ||||
} | ||||
} | ||||
|
||||
func ConvertRoles(roles []rbac.Role) []codersdk.Role { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be exported either! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using it for some tests here Line 88 in 87c474b
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should never need to use internal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking on:
|
||||
converted := make([]codersdk.Role, 0, len(roles)) | ||||
for _, role := range roles { | ||||
converted = append(converted, ConvertRole(role)) | ||||
} | ||||
return converted | ||||
} |
Uh oh!
There was an error while loading. Please reload this page.