mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: project grant join (#2525)
* fix: project grant join granted org name * fix: search granted projects
This commit is contained in:
parent
040b53305c
commit
25c009ad0a
@ -63,7 +63,7 @@ func (s *Server) ListGrantedProjects(ctx context.Context, req *mgmt_pb.ListGrant
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = queries.AppendMyResourceOwnerQuery(authz.GetCtxData(ctx).OrgID)
|
||||
err = queries.AppendGrantedOrgQuery(authz.GetCtxData(ctx).OrgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -190,6 +190,10 @@ func NewProjectGrantResourceOwnerSearchQuery(value string) (SearchQuery, error)
|
||||
return NewTextQuery(ProjectGrantColumnResourceOwner, value, TextEquals)
|
||||
}
|
||||
|
||||
func NewProjectGrantGrantedOrgIDSearchQuery(value string) (SearchQuery, error) {
|
||||
return NewTextQuery(ProjectGrantColumnGrantedOrgID, value, TextEquals)
|
||||
}
|
||||
|
||||
func (r *ProjectGrantSearchQueries) AppendMyResourceOwnerQuery(orgID string) error {
|
||||
query, err := NewProjectGrantResourceOwnerSearchQuery(orgID)
|
||||
if err != nil {
|
||||
@ -199,6 +203,15 @@ func (r *ProjectGrantSearchQueries) AppendMyResourceOwnerQuery(orgID string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ProjectGrantSearchQueries) AppendGrantedOrgQuery(orgID string) error {
|
||||
query, err := NewProjectGrantGrantedOrgIDSearchQuery(orgID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Queries = append(r.Queries, query)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r ProjectGrantSearchQueries) AppendPermissionQueries(permissions []string) error {
|
||||
if !authz.HasGlobalPermission(permissions) {
|
||||
ids := authz.GetAllPermissionCtxIDs(permissions)
|
||||
@ -240,7 +253,7 @@ func prepareProjectGrantQuery() (sq.SelectBuilder, func(*sql.Row) (*ProjectGrant
|
||||
From(projectGrantsTable.identifier()).PlaceholderFormat(sq.Dollar).
|
||||
LeftJoin(join(ProjectColumnID, ProjectGrantColumnProjectID)).
|
||||
LeftJoin(join(resourceOwnerIDColumn, ProjectGrantColumnResourceOwner)).
|
||||
LeftJoin(join(grantedOrgIDColumn, ProjectGrantColumnResourceOwner)),
|
||||
LeftJoin(join(grantedOrgIDColumn, ProjectGrantColumnGrantedOrgID)),
|
||||
func(row *sql.Row) (*ProjectGrant, error) {
|
||||
p := new(ProjectGrant)
|
||||
err := row.Scan(
|
||||
@ -289,8 +302,8 @@ func prepareProjectGrantsQuery() (sq.SelectBuilder, func(*sql.Rows) (*ProjectGra
|
||||
From(projectGrantsTable.identifier()).PlaceholderFormat(sq.Dollar).
|
||||
LeftJoin(join(ProjectColumnID, ProjectGrantColumnProjectID)).
|
||||
LeftJoin(join(resourceOwnerIDColumn, ProjectGrantColumnResourceOwner)).
|
||||
LeftJoin(join(grantedOrgIDColumn, ProjectGrantColumnResourceOwner)),
|
||||
func(rows *sql.Rows) (*ProjectGrants, error) {
|
||||
LeftJoin(join(grantedOrgIDColumn, ProjectGrantColumnGrantedOrgID)),
|
||||
func(rows *sql.Rows) (*ProjectGrants, error) {
|
||||
projects := make([]*ProjectGrant, 0)
|
||||
var count uint64
|
||||
for rows.Next() {
|
||||
|
Loading…
Reference in New Issue
Block a user