Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Duplicate action for edit product does check permission via the Elements service to determine whether the Save as new product button is shown in the cp #3819

Closed
samhibberd opened this issue Dec 17, 2024 · 6 comments
Assignees
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce

Comments

@samhibberd
Copy link

What happened?

Description

Running into this issue (#3285) with the Duplication logic, needs hooking up i think:

Image

Steps to reproduce

  1. Set $e->authorized = false via the Elements::EVENT_AUTHORIZE_DUPLICATE

Expected behavior

Should hide: Save as new product

Craft CMS version

4.12.5

Craft Commerce version

4.6.13

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@samhibberd samhibberd added bug commerce4 Issues related to Commerce v4 Craft Commerce labels Dec 17, 2024
@samhibberd
Copy link
Author

More importantly it doesn't currently prevent duplication / throw an exception in the case that the duplicate action is called and the action is not authorized. Need to ensure it calls the Elements service to hook into the service level authorization events.

@nfourtythree nfourtythree self-assigned this Dec 30, 2024
nfourtythree added a commit that referenced this issue Dec 30, 2024
…ction-for-edit-product-does-check-permission

Fixed #3819 product duplication not checking permissions
@nfourtythree
Copy link
Contributor

Thanks for reporting @samhibberd!

We have pushed a fix for this which will be included in the next release of Commerce 4.

To get this early, change your craftcms/commerce requirement in your project's composer.json to:

"require": {
  "craftcms/commerce": "4.x-dev as 4.7.2",
  "...": "..."
}

Then run composer update.

@samhibberd
Copy link
Author

Hey @nfourtythree thanks for fixing, one thing, did you also fix the issue with the 'Save as new product' action item showing even if the without permission to duplicate? (On my phone so sorry if I missed it, but I couldn't see any changes in the commit related to it).

@nfourtythree
Copy link
Contributor

Hi @samhibberd

Here is that change in the merge commit: 35e765d#diff-13c25db9415da0850f3aab0e6b303c2e5ff8f2531544be953ee5f92edcc52742R26-R32

Thanks!

@samhibberd
Copy link
Author

Been a long Christmas :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce
Projects
None yet
Development

No branches or pull requests

2 participants