mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:57:33 +00:00
fix: new es fix (#1532)
* fix: handle ListMyProjectOrgsRequestToModel queries * fix: sort orgs for admin org list by org name * fix: features converters * fix: remove last role from user grant * fix: ensure limit * fix: ensure limit Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -69,6 +69,8 @@ func setDefaultFeaturesRequestToDomain(req *admin_pb.SetDefaultFeaturesRequest)
|
||||
LoginPolicyPasswordless: req.LoginPolicyPasswordless,
|
||||
LoginPolicyRegistration: req.LoginPolicyRegistration,
|
||||
LoginPolicyUsernameLogin: req.LoginPolicyUsernameLogin,
|
||||
PasswordComplexityPolicy: req.PasswordComplexityPolicy,
|
||||
LabelPolicy: req.LabelPolicy,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,5 +86,7 @@ func setOrgFeaturesRequestToDomain(req *admin_pb.SetOrgFeaturesRequest) *domain.
|
||||
LoginPolicyPasswordless: req.LoginPolicyPasswordless,
|
||||
LoginPolicyRegistration: req.LoginPolicyRegistration,
|
||||
LoginPolicyUsernameLogin: req.LoginPolicyUsernameLogin,
|
||||
PasswordComplexityPolicy: req.PasswordComplexityPolicy,
|
||||
LabelPolicy: req.LabelPolicy,
|
||||
}
|
||||
}
|
||||
|
@@ -82,7 +82,11 @@ func (s *Server) ListMyUserGrants(ctx context.Context, req *auth_pb.ListMyUserGr
|
||||
}
|
||||
|
||||
func (s *Server) ListMyProjectOrgs(ctx context.Context, req *auth_pb.ListMyProjectOrgsRequest) (*auth_pb.ListMyProjectOrgsResponse, error) {
|
||||
res, err := s.repo.SearchMyProjectOrgs(ctx, ListMyProjectOrgsRequestToModel(req))
|
||||
r, err := ListMyProjectOrgsRequestToModel(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res, err := s.repo.SearchMyProjectOrgs(ctx, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -93,12 +97,16 @@ func (s *Server) ListMyProjectOrgs(ctx context.Context, req *auth_pb.ListMyProje
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ListMyProjectOrgsRequestToModel(req *auth_pb.ListMyProjectOrgsRequest) *grant_model.UserGrantSearchRequest {
|
||||
func ListMyProjectOrgsRequestToModel(req *auth_pb.ListMyProjectOrgsRequest) (*grant_model.UserGrantSearchRequest, error) {
|
||||
offset, limit, asc := object.ListQueryToModel(req.Query)
|
||||
return &grant_model.UserGrantSearchRequest{
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
Asc: asc,
|
||||
// Queries: queries,//TODO:user grant queries missing in proto
|
||||
queries, err := org.OrgQueriesToUserGrantModel(req.Queries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &grant_model.UserGrantSearchRequest{
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
Asc: asc,
|
||||
Queries: queries,
|
||||
}, nil
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@ func FeaturesFromModel(features *features_model.FeaturesView) *features_pb.Featu
|
||||
LoginPolicyPasswordless: features.LoginPolicyPasswordless,
|
||||
LoginPolicyRegistration: features.LoginPolicyRegistration,
|
||||
LoginPolicyUsernameLogin: features.LoginPolicyUsernameLogin,
|
||||
PasswordComplexityPolicy: features.PasswordComplexityPolicy,
|
||||
LabelPolicy: features.LabelPolicy,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,36 @@ func OrgQueryToModel(query *org_pb.OrgQuery) (*org_model.OrgSearchQuery, error)
|
||||
}
|
||||
}
|
||||
|
||||
func OrgQueriesToUserGrantModel(queries []*org_pb.OrgQuery) (_ []*grant_model.UserGrantSearchQuery, err error) {
|
||||
q := make([]*grant_model.UserGrantSearchQuery, len(queries))
|
||||
for i, query := range queries {
|
||||
q[i], err = OrgQueryToUserGrantQueryModel(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func OrgQueryToUserGrantQueryModel(query *org_pb.OrgQuery) (*grant_model.UserGrantSearchQuery, error) {
|
||||
switch q := query.Query.(type) {
|
||||
case *org_pb.OrgQuery_DomainQuery:
|
||||
return &grant_model.UserGrantSearchQuery{
|
||||
Key: grant_model.UserGrantSearchKeyOrgDomain,
|
||||
Method: object.TextMethodToModel(q.DomainQuery.Method),
|
||||
Value: q.DomainQuery.Domain,
|
||||
}, nil
|
||||
case *org_pb.OrgQuery_NameQuery:
|
||||
return &grant_model.UserGrantSearchQuery{
|
||||
Key: grant_model.UserGrantSearchKeyOrgName,
|
||||
Method: object.TextMethodToModel(q.NameQuery.Method),
|
||||
Value: q.NameQuery.Name,
|
||||
}, nil
|
||||
default:
|
||||
return nil, errors.ThrowInvalidArgument(nil, "ADMIN-ADvsd", "List.Query.Invalid")
|
||||
}
|
||||
}
|
||||
|
||||
func OrgViewsToPb(orgs []*org_model.OrgView) []*org_pb.Org {
|
||||
o := make([]*org_pb.Org, len(orgs))
|
||||
for i, org := range orgs {
|
||||
|
Reference in New Issue
Block a user