2021-08-06 13:04:49 +00:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
2021-12-14 07:19:02 +00:00
|
|
|
"context"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
|
|
user_grpc "github.com/zitadel/zitadel/internal/api/grpc/user"
|
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
auth_pb "github.com/zitadel/zitadel/pkg/grpc/auth"
|
2021-08-06 13:04:49 +00:00
|
|
|
)
|
|
|
|
|
2021-12-14 07:19:02 +00:00
|
|
|
func ListMyMembershipsRequestToModel(ctx context.Context, req *auth_pb.ListMyMembershipsRequest) (*query.MembershipSearchQuery, error) {
|
2021-08-06 13:04:49 +00:00
|
|
|
offset, limit, asc := object.ListQueryToModel(req.Query)
|
2021-12-14 07:19:02 +00:00
|
|
|
queries, err := user_grpc.MembershipQueriesToQuery(req.Queries)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
userQuery, err := query.NewMembershipUserIDQuery(authz.GetCtxData(ctx).UserID)
|
2021-08-06 13:04:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-12-14 07:19:02 +00:00
|
|
|
queries = append(queries, userQuery)
|
|
|
|
return &query.MembershipSearchQuery{
|
|
|
|
SearchRequest: query.SearchRequest{
|
|
|
|
Offset: offset,
|
|
|
|
Limit: limit,
|
|
|
|
Asc: asc,
|
|
|
|
//SortingColumn: //TODO: sorting
|
|
|
|
},
|
2021-08-06 13:04:49 +00:00
|
|
|
Queries: queries,
|
|
|
|
}, nil
|
|
|
|
}
|