mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
Fixed creating project scoped role failed from cli
This commit is contained in:
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## Unreleased
|
||||
|
||||
## Fixed
|
||||
|
||||
- Fixed creating project scoped role failed from cli [niravparikh05](https://github.com/niravparikh05)
|
||||
|
||||
## [0.1.5] - 2022-10-10
|
||||
|
||||
## Fixed
|
||||
|
||||
@@ -38,3 +38,16 @@ func GetRolePermissionsByScope(ctx context.Context, db bun.IDB, scope string) ([
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func GetRolePermissionsByNames(ctx context.Context, db bun.IDB, permissions ...string) ([]models.ResourcePermission, error) {
|
||||
var r = []models.ResourcePermission{}
|
||||
err := db.NewSelect().Table("authsrv_resourcepermission").
|
||||
ColumnExpr("authsrv_resourcepermission.name as name, authsrv_resourcepermission.description as description, authsrv_resourcepermission.scope as scope").
|
||||
Where("name IN (?)", bun.In(permissions)).
|
||||
Where("authsrv_resourcepermission.trash = ?", false).
|
||||
Scan(ctx, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
@@ -92,6 +92,13 @@ func (s *rolepermissionService) List(ctx context.Context, opts ...query.Option)
|
||||
}
|
||||
rles = append(rles, rps...)
|
||||
}
|
||||
// add partner and organization read roles as it is organization scoped yet required by all
|
||||
rps, err := dao.GetRolePermissionsByNames(ctx, s.db, partnerR, organizationR)
|
||||
if err != nil {
|
||||
return rolepermissionList, err
|
||||
}
|
||||
rles = append(rles, rps...)
|
||||
|
||||
for _, rle := range rles {
|
||||
entry := &rolev3.RolePermission{}
|
||||
entry = s.toV3Rolepermission(entry, &rle)
|
||||
|
||||
Reference in New Issue
Block a user