Skip to content

Commit

Permalink
Fixed #3819 product duplication not checking permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Dec 30, 2024
1 parent 1b40aeb commit 032c9b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft Commerce

## Unreleased

- Fixed a bug where Edit Product pages would allow duplication for users that didn’t have permission to duplicate the product. ([#3819](https://github.com/craftcms/commerce/issues/3819))

## 4.7.2 - 2024-12-18

- Fixed a bug where the Edit Order page wasn’t showing order errors.
Expand Down
5 changes: 5 additions & 0 deletions src/controllers/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ public function actionSaveProduct(bool $duplicate = false): ?Response
*/
public function actionDuplicateProduct(): ?Response
{
$product = ProductHelper::productFromPost($this->request);
if (!Craft::$app->getElements()->canDuplicate($product)) {
throw new ForbiddenHttpException('User is not permitted to duplicate this product');
}

return $this->runAction('save-product', ['duplicate' => true]);
}

Expand Down

0 comments on commit 032c9b5

Please sign in to comment.