fix: restrict order status to owner
This commit is contained in:
@@ -393,7 +393,7 @@ func (s *order) settleOrder(ctx context.Context, o *models.Order, method, extern
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *order) Status(ctx context.Context, tenantID, id int64) (*transaction_dto.OrderStatusResponse, error) {
|
||||
func (s *order) Status(ctx context.Context, tenantID, userID, id int64) (*transaction_dto.OrderStatusResponse, error) {
|
||||
o, err := models.OrderQuery.WithContext(ctx).Where(models.OrderQuery.ID.Eq(id)).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
@@ -401,6 +401,9 @@ func (s *order) Status(ctx context.Context, tenantID, id int64) (*transaction_dt
|
||||
}
|
||||
return nil, errorx.ErrDatabaseError.WithCause(err)
|
||||
}
|
||||
if userID > 0 && o.UserID != userID {
|
||||
return nil, errorx.ErrForbidden.WithMsg("无权访问该订单")
|
||||
}
|
||||
if tenantID > 0 && o.TenantID > 0 && o.TenantID != tenantID {
|
||||
return nil, errorx.ErrForbidden.WithMsg("租户不匹配")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user