2
votes

I want to do some stuff in the users/login action before login user.

For example i have captcha code on each 3rd submit of the login form and i want to check if the captcha code is valid. If it is not valid i want user to fill it up correctly first, before is able to submit. And if captcha is ok i want to use Auth->login()

Unfortunately when submit the form Auth->data['User']['username'] and Auth->data['User']['password'] are filled and the login is done behind(automagically)...

How can i disable automagically user login of the Auth component and do that only from Auth->login($data)?

4

4 Answers

1
votes

you can write - like I did (with similar captcha stuff) - your own AuthExt component (or name it whatever you like) which extends the Auth Component

then override the login() method so that it suits your need

1
votes

One option, depending on your project, is to upgrade to CakePHP 2.0 as there the auto-magic behavior has been removed, see Identifying users and logging them in.

1
votes

one hack is to set the Auth->loginAction to a non-existent action (non-existent so that no one can access that), so Auth won't auto login in login(), you can do your own logic in there (password hashing is still automatically applied).

0
votes

use this :

function beforeFilter(){
}

in this function u can do all things that want before anything happens in your controller.