-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Use route ID when creating secret keys in backend menus instead of route name #17650
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
Conversation
Hi @lfolco. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Thanks a lot Laura! I'll process this and let you know if we have any questions. |
Hi @miguelbalparda, thank you for the review. |
@@ -92,6 +99,7 @@ public function __construct( | |||
\Magento\Backend\Model\Auth\Session $authSession, | |||
\Magento\Backend\Model\Menu\Config $menuConfig, | |||
\Magento\Framework\Locale\ResolverInterface $localeResolver, | |||
\Magento\Framework\App\Route\ConfigInterface $routeConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, inject new dependencies according to our Backward compatible development guide
Please check now, I have committed the requested changes. |
…instead of route name #17650
Hi @lfolco. Thank you for your contribution. |
Description
If you use a different route ID and front name in the adminhtml/routes.xml file, you will get redirected to the dashboard when clicking on the menu link.
This is because the route front name is used to generate the secret key when creating the menu, and route ID is used to generate the secret key for key validation.
The method
\Magento\Backend\Model\Url::getSecretKey()
takes three parameters: route ID, action path, and action. When creating links for the menu,Magento\Backend\Block\Menu::_callbackSecretKey($match)
is reading the URL paths from XML, which are using front names. I have injected\Magento\Framework\App\Route\ConfigInterface
in order to usegetRouteByFrontName($routeName)
in order to get the proper route ID.Fixed Issues (if relevant)
Manual testing scenarios
action
attribute.Contribution checklist