Reputation: 41
Here my controller name is AucUsersController. After use auth component it is finding userscontroller.I want to change this directory.I have tried by bellow code but it's not working.
public $components = array('Paginator'=>array('limit'=>2),'Auth'=>array(
'Controller'=>'AucUsers',
'loginRedirect' => array('controller' => 'aucusers','action' => 'index'),
'logoutRedirect' => array('controller' => 'aucusers','action' => 'index'),
'authError'=>'You can not access this page!!',
));
How can I change this default controller ?
Upvotes: 1
Views: 1741
Reputation: 805
CakePHP by default uses users/login for loginAction, loginAction is the property where you define the controller and action where cake does the login
public $components = array('Paginator'=>array('limit'=>2),'Auth'=>array(
'loginAction' => array(
'controller' => 'aucusers',
'action' => 'login'
),
'loginRedirect' => array('controller' => 'aucusers','action' => 'index'),
'logoutRedirect' => array('controller' => 'aucusers','action' => 'index'),
'authError'=>'You can not access this page!!',
));
loginRedirect - It represents where user should redirect to after login logoutRedirect - It represents where user should redirect to after logout
Upvotes: 3
Reputation: 2277
I believe that if you want to change the default controller you have to set the UserModel
option. I set it at beforeFilter method. So in your case it will be.
/**
* beforeFilter method
*
* @return void
*/
public function beforeFilter() {
$this->Auth->authenticate = array(
'Form' => array(
'userModel' => 'AucUser',
)
);
return parent::beforeFilter();
}
I haven't seen in the docs to have any controller option.
Upvotes: 0