CakeDC / users

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

Routes broken #990

Closed EronarDiaras closed 2 years ago

EronarDiaras commented 2 years ago

I just noticed that the CakeDCUsers pages aren't working. (only the pages)

config/routes.php:

$builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
//$builder->connect('/{controller}', ['action' => 'index', 'plugin' => 'CakeDC/Users', '_ext' => NULL,]);
//$builder->connect('/{controller}/{action}/*', ['plugin' => 'CakeDC/Users', '_ext' => NULL,]);

missin-route

projects-work

But if I overwrite the config/routes.php file:

$builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
$builder->connect('/{controller}', ['action' => 'index', 'plugin' => 'CakeDC/Users', '_ext' => NULL,]);
$builder->connect('/{controller}/{action}/*', ['plugin' => 'CakeDC/Users', '_ext' => NULL,]);

will work: missin-route-w

its breaks down: Clipboard02

What is wrong? What makes this possible?

EronarDiaras commented 2 years ago

I added these lines to the config/routes.php:

$routes->scope('/users/', function (RouteBuilder $builder) {
        $builder->connect('/{controller}', ['action' => 'index', 'plugin' => 'CakeDC/Users', '_ext' => NULL,]);
        $builder->connect('/{controller}/{action}/*', ['plugin' => 'CakeDC/Users', '_ext' => NULL,]);
        $builder->fallbacks();
    });

(Above these lines: "$routes->scope('/', function (RouteBuilder $builder) {")

And now everything works. But is that a good solution?

rochamarcelo commented 2 years ago

@EronarDiaras It looks like you have a link in your layout using ['controller' => 'Projects', 'action' => 'index'] since the layout is being used for /profile action you must change to something like ['controller' => 'Projects', 'action' => 'index', 'plugin' => false]

EronarDiaras commented 2 years ago

True... Thank you very much!!!