venveo / craft-redirect

MIT License
3 stars 2 forks source link

403 on create redirect #69

Closed shennyg closed 1 month ago

shennyg commented 1 month ago

Hi there. Clicking the New Redirect button fails with a "User not authorized to save this redirect."

It's failing here: https://github.com/venveo/craft-redirect/blob/develop-v4/src/controllers/RedirectsController.php#L106-L109

See this debugging session, Redirect. php:1089, venveo\redirect|elements|Redirect-›canSave () fails when checking for $checkPermission = "editsite:170c66d0-4ee6-473d-bf02-03268bb01f24": image

We have the permissions to manage redirects for that users.

Switching the user to Admin fixes error.

To recreate, create a new non-multisite Craft 4 site, add the plugin v4 beta 7, create a new user without full admin permissions but all plugin permissions. Login as user, see error when click on new redirect button.

Thanks so much! Shen

Mosnar commented 1 month ago

Thanks for reporting. I wonder if it was this change... https://github.com/venveo/craft-redirect/commit/8a1acbc2542c8eb990e19ba992b49c9d84bded61

shennyg commented 1 month ago

Thanks for the quick response, yes I believe so. If you look at the usage of $user->can('editSite:' it's almost always checking for multisite first. See: https://github.com/search?q=repo:craftcms/cms%20%22editSite:%22&type=code

Mosnar commented 1 month ago

Just tagged 4.0.0-beta.8, let me know if that doesn't fix it for you!