Fix get-all-objects API 403 issue

This commit is contained in:
Yang Luo 2023-12-15 21:30:38 +08:00
parent b31a317585
commit 468ceb6b71
2 changed files with 6 additions and 0 deletions

View File

@ -92,6 +92,9 @@ p, *, *, GET, /api/get-plan, *, *
p, *, *, GET, /api/get-subscription, *, *
p, *, *, GET, /api/get-provider, *, *
p, *, *, GET, /api/get-organization-names, *, *
p, *, *, GET, /api/get-all-objects, *, *
p, *, *, GET, /api/get-all-actions, *, *
p, *, *, GET, /api/get-all-roles, *, *
`
sa := stringadapter.NewAdapter(ruleText)

View File

@ -271,6 +271,9 @@ func getRolesByUserInternal(userId string) ([]*Role, error) {
if err != nil {
return roles, err
}
if user == nil {
return nil, fmt.Errorf("The user: %s doesn't exist", userId)
}
query := ormer.Engine.Alias("r").Where("r.users like ?", fmt.Sprintf("%%%s%%", userId))
for _, group := range user.Groups {