diff --git a/vendor/magento/module-company/Plugin/AsyncOrder/Model/PermissionCheckPlugin.php b/vendor/magento/module-company/Plugin/AsyncOrder/Model/PermissionCheckPlugin.php deleted file mode 100644 index 69a939ecc95f..000000000000 --- a/vendor/magento/module-company/Plugin/AsyncOrder/Model/PermissionCheckPlugin.php +++ /dev/null @@ -1,77 +0,0 @@ -userContext = $userContext; - $this->companyManagement = $companyManagement; - } - - /** - * Before placing order permission check - * - * @param AsyncPaymentInformationCustomerPublisher $subject - * @param string $cartId - * @param PaymentInterface $paymentMethod - * @param AddressInterface|null $billingAddress - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @throws AuthorizationException - */ - public function beforeSavePaymentInformationAndPlaceOrder( - AsyncPaymentInformationCustomerPublisher $subject, - string $cartId, - PaymentInterface $paymentMethod, - AddressInterface $billingAddress = null - ) { - $customerId = (int)$this->userContext->getCustomer()->getId() ?: 0; - if ($customerId) { - $company = $this->companyManagement->getByCustomerId($customerId); - if ($company !== null && $company->getExtensionAttributes()->getIsPurchaseOrderEnabled()) { - throw new AuthorizationException(__( - 'You are not authorized to access this resource.' - )); - } - } - return null; - } -} diff --git a/vendor/magento/module-company/etc/di.xml b/vendor/magento/module-company/etc/di.xml index 97cfbb9df300..92f451a96b16 100755 --- a/vendor/magento/module-company/etc/di.xml +++ b/vendor/magento/module-company/etc/di.xml @@ -260,9 +260,6 @@ Magento\Company\Acl\AclResource\Provider - - - Magento\Company\Acl\AclResource\Provider diff --git a/vendor/magento/module-purchase-order/Plugin/AsyncOrder/Model/PermissionCheckPlugin.php b/vendor/magento/module-purchase-order/Plugin/AsyncOrder/Model/PermissionCheckPlugin.php new file mode 100644 index 000000000000..110a07875daf --- /dev/null +++ b/vendor/magento/module-purchase-order/Plugin/AsyncOrder/Model/PermissionCheckPlugin.php @@ -0,0 +1,63 @@ +config = $config; + } + + /** + * Before placing order permission check + * + * @param AsyncPaymentInformationCustomerPublisher $subject + * @param string $cartId + * @param PaymentInterface $paymentMethod + * @param AddressInterface|null $billingAddress + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @throws AuthorizationException + */ + public function beforeSavePaymentInformationAndPlaceOrder( + AsyncPaymentInformationCustomerPublisher $subject, + string $cartId, + PaymentInterface $paymentMethod, + AddressInterface $billingAddress = null + ) { + if ($this->config->isEnabledForCurrentCustomerAndWebsite()) { + throw new AuthorizationException(__('You are not authorized to access this resource.')); + } + } +} diff --git a/vendor/magento/module-purchase-order/etc/di.xml b/vendor/magento/module-purchase-order/etc/di.xml index 2c0c3f8ade36..acdc58579d4a 100644 --- a/vendor/magento/module-purchase-order/etc/di.xml +++ b/vendor/magento/module-purchase-order/etc/di.xml @@ -313,4 +313,7 @@ + + +