I have two type of users in my website. 1.User (Frontend) 2.Admin (Backend)
I used cakephp auth component for login both type of user. my problem is that when i login using one type of users i will automatically login to other type of user for example i login as user from frontend but when i refresh backed it will show me logedin and same problem with admin type of user.
Below are my auth Code separate for admin and user.
This is AppController.php file in app/Controller
public function beforeFilter() {
if($this->Auth->user()){
$this->set('logged_in', true);
}else{
$this->set('logged_in', false);
}
//Configure AuthComponent
$this->Auth->userScope = array('User.is_active' => '1');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'signin','plugin' => 'umgmt');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'signin','plugin' => 'umgmt');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index','plugin' => false);
}
This is my admin plugin controller code
public $components = array(
'Auth' => array(
'authenticate' => array(
'Form' => array(
'userModel' => 'Admin',
'fields' => array(
'username' => 'username',
'password' => 'password'
),
'scope'=>array('Admin.is_active' => 1)
)
)
)
);
public function beforeFilter() {
$this->Auth->loginAction = array('controller' => 'admins', 'action' => 'index');
$this->Auth->logoutRedirect = array('controller' => 'admins', 'action' => 'index');
$this->Auth->loginRedirect = array('controller' => 'admins', 'action' => 'dashboard');
}
I am using cakephp 2.4.1
Please help me