I have a website which had initially a login system for only users of the website. And I am using CakePHP's form based Auth.
Now I have Supplier
and Distributer
accounts and want to allow both types of user to Login to the website. But their username and password are stored in corresponding tables.
in my beforeFilter
I have Auth code like
$this->Auth->authenticate = array(
'Form' => array(
'userModel' => 'User',
'fields' => array(
'username' => 'username',
'password' => 'password'
),
'scope' => array(
'User.active' => 1,
)
)
);
if(isset($this->request->params['admin']) && ($this->request->params['prefix'] == 'admin')) {
if($this->Session->check('Auth.User')) {
$this->set('authUser', $this->Auth->user());
$loggedin = $this->Session->read('Auth.User');
$this->set(compact('loggedin'));
$this->layout = 'admin';
}
}
How may I extend my code that it accomodates both above mentioned types too.