mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: refactor roles to support multiple permission sets scoped by org id (#20186)
In preparation for adding the "member" permission level, which will also be grouped by org ID, do a bit of a refactor to make room for it and the existing "org" level to live in the same `map`
This commit is contained in:
@@ -124,7 +124,6 @@ func ConvertDBRole(dbRole database.CustomRole) (rbac.Role, error) {
|
||||
Identifier: dbRole.RoleIdentifier(),
|
||||
DisplayName: dbRole.DisplayName,
|
||||
Site: convertPermissions(dbRole.SitePermissions),
|
||||
Org: nil,
|
||||
User: convertPermissions(dbRole.UserPermissions),
|
||||
}
|
||||
|
||||
@@ -134,8 +133,10 @@ func ConvertDBRole(dbRole database.CustomRole) (rbac.Role, error) {
|
||||
}
|
||||
|
||||
if dbRole.OrganizationID.UUID != uuid.Nil {
|
||||
role.Org = map[string][]rbac.Permission{
|
||||
dbRole.OrganizationID.UUID.String(): convertPermissions(dbRole.OrgPermissions),
|
||||
role.ByOrgID = map[string]rbac.OrgPermissions{
|
||||
dbRole.OrganizationID.UUID.String(): {
|
||||
Org: convertPermissions(dbRole.OrgPermissions),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user