fixed payments access requireing organization reference
This commit is contained in:
@@ -368,11 +368,12 @@ func (*Payment) Collection() string {
|
||||
|
||||
// PaymentFilter enables filtered queries.
|
||||
type PaymentFilter struct {
|
||||
States []PaymentState
|
||||
SourceRef string
|
||||
DestinationRef string
|
||||
Cursor string
|
||||
Limit int32
|
||||
States []PaymentState
|
||||
SourceRef string
|
||||
OrganizationRef string
|
||||
DestinationRef string
|
||||
Cursor string
|
||||
Limit int32
|
||||
}
|
||||
|
||||
// PaymentList contains paginated results.
|
||||
|
||||
@@ -200,6 +200,14 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
|
||||
query = query.And(endpointFilter)
|
||||
}
|
||||
}
|
||||
if ref := strings.TrimSpace(filter.OrganizationRef); ref != "" {
|
||||
orgRef, err := bson.ObjectIDFromHex(ref)
|
||||
if err != nil {
|
||||
p.logger.Warn("Failed to decode organization reference", zap.Error(err), zap.String("provided_org_ref", ref))
|
||||
return nil, err
|
||||
}
|
||||
query.And(repository.OrgFilter(orgRef))
|
||||
}
|
||||
|
||||
if ref := strings.TrimSpace(filter.DestinationRef); ref != "" {
|
||||
if endpointFilter := endpointQuery("intent.destination", ref); endpointFilter != nil {
|
||||
@@ -223,6 +231,7 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
|
||||
decoder := func(cur *mongo.Cursor) error {
|
||||
item := &model.Payment{}
|
||||
if err := cur.Decode(item); err != nil {
|
||||
p.logger.Warn("Failed to decode item", zap.Error(err), zap.Any("item", cur.Current))
|
||||
return err
|
||||
}
|
||||
payments = append(payments, item)
|
||||
|
||||
Reference in New Issue
Block a user