Fixed creating project scoped role failed from cli

This commit is contained in:
Nirav Parikh
2022-10-11 14:49:56 +05:30
parent 25d26e8900
commit f0952a37d8
3 changed files with 24 additions and 0 deletions
+4
View File
@@ -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
+13
View File
@@ -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
}
+7
View File
@@ -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)