Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

actionMap error #26

Closed
djonatanb opened this issue Jan 26, 2016 · 13 comments
Closed

actionMap error #26

djonatanb opened this issue Jan 26, 2016 · 13 comments
Labels

Comments

@djonatanb
Copy link
Contributor

I think that I cannot map actions from xxxxxx.com/users/request_password to action request_password, it goes to action requestPassword instead. With that the action map doesn't seem to work. if I change the action map it works.
Am I doing something wrong ?

@burzum burzum added the bug label Jan 26, 2016
@burzum
Copy link
Owner

burzum commented Jan 26, 2016

I think there has been a change in the dispatcher of the CakePHP framework itself. What version are you using?

@djonatanb
Copy link
Contributor Author

3.1.7

@burzum
Copy link
Owner

burzum commented Jan 26, 2016

So just changing all the methods from underscored to camelCased in the components map fixes the problem for you? I couldn't find anything related to that in the 3.1 changelog and I have three apps using that version without that I've noticed trouble.

@djonatanb
Copy link
Contributor Author

Inside the UserToolComponent

'actionMap' => [
            'index' => [
                'method' => 'listing',
                'view' => 'Burzum/UserTools.UserTools/index',
            ],
            'register' => [
                'method' => 'register',
                'view' => 'Burzum/UserTools.UserTools/register'
            ],
            'login' => [
                'method' => 'login',
                'view' => 'Burzum/UserTools.UserTools/login',
            ],
            'logout' => [
                'method' => 'logout',
                'view' => null
            ],
            'resetPassword' => [
                'method' => 'resetPassword',
                'view' => 'Burzum/UserTools.UserTools/reset_password',
            ],
            'requestPassword' => [
                'method' => 'requestPassword',
                'view' => 'Burzum/UserTools.UserTools/request_password',
            ],
            'changePassword' => [
                'method' => 'changePassword',
                'view' => 'Burzum/UserTools.UserTools/change_password',
            ],
            'verifyEmail' => [
                'method' => 'verifyEmailToken',
                'view' => 'Burzum/UserTools.UserTools/verify_email',
            ],
            'view' => [
                'method' => 'getUser',
                'view' => 'Burzum/UserTools.UserTools/view',
            ]
        ]

in my boostrap

Configure::write('UserTools.Component', [
    'actionMap' => [
        'index' => [
            'method' => 'listing',
            'view' => 'UserTools.UserTools/index',
        ],
        'register' => [
            'method' => 'register',
            'view' => 'register'
        ],
        'changePassword' => [
            'method' => 'changePassword',
            'view' => 'change_password'
        ],
        'login' => [
            'method' => 'login',
            'view' => 'login',
        ],
        'logout' => [
            'method' => 'logout',
            'view' => null
        ],
    ],
]);

that's how it works for me, I tried to access it like request-password or request_password but the $action in

public function mapAction() {
        $action = $this->request->params['action'];

was always returning it camelBacked. When I changed it worked.

@djonatanb
Copy link
Contributor Author

isn't it part of the new conventions to have actions camelBacked ?

@burzum
Copy link
Owner

burzum commented Jan 26, 2016

I'm pretty sure it is because of PSR. I just can't see where I have missed that change to the CakePHP core. I've checked the release notes but haven't seen it there. With 3.0 it was working the way it is. I fear there is a difference between old and new apps. So the difference might be in the cakephp/app package, loading another dispatcher filter or something like that.

https://github.com/cakephp/app/releases

3.1.0-beta …
CakePHP App Skeleton 3.1.0-beta
* Default to DashedRoute.

@djonatanb
Copy link
Contributor Author

Not sure if I understand it all, but for me the problem seemed to be the action name. As far as I understand you are using action names with underscore as the key in the config array.

Are you using dashedRoute in the projects with cakephp3.0 that work ok with the underscore actions ?

burzum pushed a commit that referenced this issue Jan 27, 2016
@burzum
Copy link
Owner

burzum commented Jan 27, 2016

@djonatanb no need to understand it, I've fixed it in a backward compatible way. Would you please mind switching to the develop branch of the plugin for a moment? It's fixed there. After your feedback I'll tag version 1.0.3.

@djonatanb
Copy link
Contributor Author

ok, gotcha, will do that

@djonatanb
Copy link
Contributor Author

The routing is working for me now. Thanks, I'll see if I can implement the user registration by invitation and make a pull request at some point.

@burzum
Copy link
Owner

burzum commented Jan 28, 2016

A PR for what? If you want an user registration you can re-use the token mechanism. Just trigger the email with the verification token when the admin creates the user and disable the user registration.

@burzum
Copy link
Owner

burzum commented Jan 28, 2016

I've merged to master and tagged 1.0.3 Thank you.

@burzum burzum closed this as completed Jan 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants