2021-08-06 15:04:49 +02:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
2021-12-14 08:19:02 +01:00
|
|
|
"context"
|
|
|
|
|
2022-04-27 01:01:45 +02: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 15:04:49 +02:00
|
|
|
)
|
|
|
|
|
2021-12-14 08:19:02 +01:00
|
|
|
func ListMyMembershipsRequestToModel(ctx context.Context, req *auth_pb.ListMyMembershipsRequest) (*query.MembershipSearchQuery, error) {
|
2021-08-06 15:04:49 +02:00
|
|
|
offset, limit, asc := object.ListQueryToModel(req.Query)
|
2021-12-14 08:19:02 +01: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 15:04:49 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-12-14 08:19:02 +01:00
|
|
|
queries = append(queries, userQuery)
|
|
|
|
return &query.MembershipSearchQuery{
|
|
|
|
SearchRequest: query.SearchRequest{
|
|
|
|
Offset: offset,
|
|
|
|
Limit: limit,
|
|
|
|
Asc: asc,
|
|
|
|
//SortingColumn: //TODO: sorting
|
|
|
|
},
|
2021-08-06 15:04:49 +02:00
|
|
|
Queries: queries,
|
|
|
|
}, nil
|
|
|
|
}
|