authentication - Cakephp Auth multiple login redirect -
within cakephp app, have users table, fields username, password, , role. role determines controllers , actions can access. 2 types of main roles have: admin , customer. hence admins , customers should allowed access respective controllers , actions.
however under appcontroller, has single redirect non logged in users leads same controller , action login page, regardless of whether user trying access admin page or customer page.
i have 2 different login pages, 1 admins , 1 customers. how can achieve this?
class appcontroller extends controller { public $components = array( 'debugkit.toolbar', 'session', 'auth'=>array( 'loginredirect'=>array('controller'=>'access', 'action'=>'login'), 'logoutredirect'=>array('controller'=>'access', 'action'=>'logout'), 'autherror'=>'you cannot access page', 'authorize'=>array('controller') ) );
you forget set loginaction .. class appcontroller extends controller {
public $components = array( 'debugkit.toolbar', 'session', 'auth'=>array( 'loginaction'=>array('controller'=>'users','action'=>'login'), 'loginredirect'=>array('controller'=>'access', 'action'=>'login'), 'logoutredirect'=>array('controller'=>'access', 'action'=>'logout'), 'autherror'=>'you cannot access page', 'authorize'=>array('controller') ) );
Comments
Post a Comment