mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 00:27:31 +00:00
fix: queries (#2548)
* fix(second_factors): correct query, rename method * fix(multi_factors): correct query, correct naming * fix(project_grant): add project_id to queries * fix: simplify project id query constructor
This commit is contained in:
@@ -107,7 +107,7 @@ func (s *Server) RemoveIDPFromLoginPolicy(ctx context.Context, req *mgmt_pb.Remo
|
||||
}
|
||||
|
||||
func (s *Server) ListLoginPolicySecondFactors(ctx context.Context, req *mgmt_pb.ListLoginPolicySecondFactorsRequest) (*mgmt_pb.ListLoginPolicySecondFactorsResponse, error) {
|
||||
result, err := s.query.SecondFactorsByID(ctx, authz.GetCtxData(ctx).OrgID)
|
||||
result, err := s.query.SecondFactorsByOrg(ctx, authz.GetCtxData(ctx).OrgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func (s *Server) RemoveSecondFactorFromLoginPolicy(ctx context.Context, req *mgm
|
||||
}
|
||||
|
||||
func (s *Server) ListLoginPolicyMultiFactors(ctx context.Context, req *mgmt_pb.ListLoginPolicyMultiFactorsRequest) (*mgmt_pb.ListLoginPolicyMultiFactorsResponse, error) {
|
||||
res, err := s.query.MultiFactorsByID(ctx, authz.GetCtxData(ctx).OrgID)
|
||||
res, err := s.query.MultiFactorsByOrg(ctx, authz.GetCtxData(ctx).OrgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -27,16 +27,16 @@ func (s *Server) ListProjectGrants(ctx context.Context, req *mgmt_pb.ListProject
|
||||
return nil, err
|
||||
}
|
||||
queries.AppendMyResourceOwnerQuery(authz.GetCtxData(ctx).OrgID)
|
||||
domains, err := s.query.SearchProjectGrants(ctx, queries)
|
||||
grants, err := s.query.SearchProjectGrants(ctx, queries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListProjectGrantsResponse{
|
||||
Result: proj_grpc.GrantedProjectViewsToPb(domains.ProjectGrants),
|
||||
Result: proj_grpc.GrantedProjectViewsToPb(grants.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(
|
||||
domains.Count,
|
||||
domains.Sequence,
|
||||
domains.Timestamp,
|
||||
grants.Count,
|
||||
grants.Sequence,
|
||||
grants.Timestamp,
|
||||
),
|
||||
}, nil
|
||||
}
|
||||
@@ -57,11 +57,11 @@ func (s *Server) AddProjectGrant(ctx context.Context, req *mgmt_pb.AddProjectGra
|
||||
}
|
||||
|
||||
func (s *Server) UpdateProjectGrant(ctx context.Context, req *mgmt_pb.UpdateProjectGrantRequest) (*mgmt_pb.UpdateProjectGrantResponse, error) {
|
||||
userGrants, err := s.usergrant.UserGrantsByProjectAndGrantID(ctx, req.ProjectId, req.GrantId)
|
||||
grants, err := s.usergrant.UserGrantsByProjectAndGrantID(ctx, req.ProjectId, req.GrantId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
grant, err := s.command.ChangeProjectGrant(ctx, UpdateProjectGrantRequestToDomain(req), authz.GetCtxData(ctx).OrgID, userGrantsToIDs(userGrants)...)
|
||||
grant, err := s.command.ChangeProjectGrant(ctx, UpdateProjectGrantRequestToDomain(req), authz.GetCtxData(ctx).OrgID, userGrantsToIDs(grants)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
func listProjectGrantsRequestToModel(req *mgmt_pb.ListProjectGrantsRequest) (*query.ProjectGrantSearchQueries, error) {
|
||||
offset, limit, asc := object.ListQueryToModel(req.Query)
|
||||
queries, err := ProjectGrantQueriesToModel(req.Queries)
|
||||
queries, err := ProjectGrantQueriesToModel(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -28,15 +28,22 @@ func listProjectGrantsRequestToModel(req *mgmt_pb.ListProjectGrantsRequest) (*qu
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ProjectGrantQueriesToModel(queries []*proj_pb.ProjectGrantQuery) (_ []query.SearchQuery, err error) {
|
||||
q := make([]query.SearchQuery, len(queries))
|
||||
for i, query := range queries {
|
||||
q[i], err = ProjectGrantQueryToModel(query)
|
||||
func ProjectGrantQueriesToModel(req *mgmt_pb.ListProjectGrantsRequest) (_ []query.SearchQuery, err error) {
|
||||
queries := make([]query.SearchQuery, 0, len(req.Queries)+1)
|
||||
for _, query := range req.Queries {
|
||||
q, err := ProjectGrantQueryToModel(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
queries = append(queries, q)
|
||||
}
|
||||
return q, nil
|
||||
projectIDQuery, err := query.NewProjectGrantProjectIDSearchQuery(req.ProjectId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
queries = append(queries, projectIDQuery)
|
||||
|
||||
return queries, nil
|
||||
}
|
||||
|
||||
func ProjectGrantQueryToModel(apiQuery *proj_pb.ProjectGrantQuery) (query.SearchQuery, error) {
|
||||
|
Reference in New Issue
Block a user