Problem/Motivation

Once an order belongs to an organization, the organization drives access (fail-closed): uid ownership applies only to orders without an organization, so a buyer who leaves the organization loses access. Only the module that owns membership (commerce_b2b) grants access back. Parent: #3638816: [META] Commerce 4.x roadmap.

Depends on the 4.0 access seams (the checkout and update_cart order operations), not in 4.x yet.

Proposed resolution

Withdraw the uid grants where they are granted, each a check on $order->getOrganizationId() === NULL; no shared ownership service. commerce_checkout and commerce_payment stay agnostic of organizations.

  • OrderAccessControlHandler, view: "view own commerce_order" only for orders without an organization.
  • OrderAccessControlHandler, checkout: the uid check only for orders without an organization; forbidden when the order's organization is unpublished.
  • commerce_cart's order access hook: neutral for orders with an organization (view, update_cart).
  • commerce_cart's QueryAccessSubscriber: leaves out carts with an organization.
  • OrderQueryAccessHandler, "view own": the uid condition also requires no organization. Not listed in the design doc, but without it "My orders" lists organization orders that entity access then denies.

User interface changes

With commerce_organization alone, a member cannot view, edit or check out their own organization cart or orders; admins still can. Orders without an organization get the same access as today.

Remaining tasks

  • Kernel tests for entity and query access, with and without an organization.

Issue fork commerce-3641083

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jsacksick created an issue. See original summary.

  • jsacksick committed b1a85e8d on 4.x
    feat: #3641083 Restrict uid-based order access to orders without an...
jsacksick’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.