[5.x]: User is not authorized to perform this action
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
What happened?
Description
The user I'm signed in with is Admin. But, I'm unable to remove a nested entry in a matrix field. I can update the content in the selected nested entry. The matrix can add max 1 entry. The entry type selected in the matrix is updateable after creating, but I can't remove the nested element. Whenever I click remove in the options for the field, I get the following error even though my user is Admin: User is not authorized to perform this action
Trace:
2024-12-05 21:07:09 [web.ERROR] [yii\web\HttpException:403] yii\web\ForbiddenHttpException: User is not authorized to perform this action in /app/backend/vendor/craftcms/cms/src/controllers/NestedElementsController.php:65
Stack trace:
#0 /app/backend/vendor/yiisoft/yii2/base/Controller.php(176): craft\controllers\NestedElementsController->beforeAction(Object(yii\base\InlineAction))
#1 /app/backend/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('delete', Array)
#2 /app/backend/vendor/craftcms/cms/src/web/Application.php(350): yii\base\Module->runAction('nested-elements...', Array)
#3 /app/backend/vendor/craftcms/cms/src/web/Application.php(649): craft\web\Application->runAction('nested-elements...', Array)
#4 /app/backend/vendor/craftcms/cms/src/web/Application.php(312): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#5 /app/backend/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#6 /app/backend/web/index.php(12): yii\base\Application->run()
#7 {main} {"memory":4049240,"exception":"[object] (yii\\web\\ForbiddenHttpException(code: 0): User is not authorized to perform this action at /app/backend/vendor/craftcms/cms/src/controllers/NestedElementsController.php:65)"}
Steps to reproduce
- Login to the cms as an admin account.
- Add a matrix field to a sections entry type, and allow it to add max 1 entry type.
- Add the entry type to the matrix field in the entry, and save. It worked saving.
- Try to remove the nested entry type.
- It fails with the errors described.
Expected behavior
I would expect that the nested were deleted, and I could then add a new nested entry.
Actual behavior
I can't delete the nested entry.
Craft CMS version
5.5.5
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with craft/controllers/NestedElementsController.php at line 65 and reproduce the matrix-field deletion flow described in the issue using Craft CMS 5.5.5. Confirm that an admin can remove the nested entry after it has been saved, without the authorization error, and verify that another nested entry can then be added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- authorization, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100