I have 2 authenticate method for Auth component. Default and Special.
First method is for all users, and Special for my friends…
I want to change authenticate method to Special when posted role is equal to 2..
So I put this in my UsersController login method:
if($this->request->data['role'] == 2){
$this->Auth->authenticate = 'Special';
echo 'Method changed!';
}
if($this->Auth->login()){
......
}
and if AppController, where I set $components:
public $components = array('RequestHandler', 'Session',
'Auth' => array('authenticate' => 'Default'));
but, when I send a form with role=2, it prints Method changed but won’t change the authenticate method and use Default method..
Have I made a mistake?
I’ve a simplier solution :
In your controller, define your new authenticate array :
Then to make your changes effective in your application, simply write :
That’s all 🙂