CakeDC / users

Users Plugin for CakePHP
https://www.cakedc.com
Other
520 stars 296 forks source link

Missing Routes #1016

Closed phila088 closed 1 year ago

phila088 commented 1 year ago

I am experiencing an issue where if I am not logged in and the default template is displayed, I get an error about missing routes. This is also happening while attempting to go to profile while logged in as well. It is connected to the links that I am building using $this->Url->build() from CakePHP. Each URL built in this way causes the error to throw regarding missing routes

A route matching "array ( 'controller' => 'WorkOrders', 'action' => 'index', 'plugin' => 'CakeDC/Users', '_ext' => NULL, )" could not be found.

[
    '_scheme' => 'http',
    '_host' => 'bgm.aphii.co',
    '_port' => null,
    '_base' => '',
    'params' => [
        'pass' => [ ],
        'plugin' => 'CakeDC/Users',
        'controller' => 'Users',
        'action' => 'profile',
        '_matchedRoute' => '/profile/*',
        '_ext' => null,
    ],
]

It was causing an issue while not logged in, that was solved by disabling the default template for the login page, but this does not solve the issue anywhere else, unless I do like before.

Is this an issue with the way the URLs for the links are being built by me?

I can manually add the route for each link, and it will stop the error, but I feel that is counterintuitive to the auto routing.

rochamarcelo commented 1 year ago

When you create a link(with Html->link or similar) that can be displayed on plugin pages or prefixed urls, you should pass the value false to plugin, in your case you should have:

$this->Html->link('My Page', array('controller' => 'WorkOrders', 'action' => 'index', 'plugin' => false, 'prefix' => false))

phila088 commented 1 year ago

Thank you a million... I appreciate the help!