CakeDC / users

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

Cake\Routing\Exception\MissingRouteException when trying to login #958

Closed bradkeifer closed 3 years ago

bradkeifer commented 3 years ago

Hi, This is the same issue that was raised by @juerujin in issue 935. The solution that he/she implemented did not solve the root cause of the issue and is unsatisfactory for my application.

My requirement is to allow unauthenticated access to some of my pages. Prior to installing CakeDC/Users plugin, I had my app working fine with the CakePHP authentication and authorisation plugins. I have now installed the CakeDC/Users plugin and converted the Html->link helper calls in my view to the AuthLink->link helper calls. This is working great for cases where users are not logged in and also when they are logged in.

However, the exception is being raised when a user attempts to login from a call to my_app_url/login.

I am running CakePHP version 4.2.8 and CakeDC/Users version 9.0.5.

The exception error I get is:

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

An extract from my permissions.php config is:

$permissions = [
    //all bypass
    [
        // anyone can view the static pages
        'role' => '*',
        'controller' => 'Pages',
        'action' => ['display'],
        'bypassAuth' => true,
    ],
    [
        // anyone can Find Tracks and download them
        'role' => '*',
        'controller' => 'Tracks',
        'action' => ['mapview', 'mapview#content', 'downloadFile'],
        'bypassAuth' => true,
    ],

I am not a php guru, but it seems that the Users controller in CakeDC/Users is trying to resolve a route which has nothing to do with the request to login.

Any suggestions on what else I should check for in my configuration? Thanks for your help.

bradkeifer commented 3 years ago

I worked out a solution. :-)

In the end, it was fairly simple. I followed the instructions to extend the plugin by creating my own local Users Model and Controller and that solved the problem. I guess it makes sense, in that the namespace used for the User model, views and controller is in the App namespace once you extend the plugin.

I hope this helps someone else who may struggle with the same issue.