Thursday, November 26, 2015

Yii Redirect to login for unauthorized user


public function accessRules()
 {
  return array(
   
   array('allow', // allow admin user to perform 'admin' and 'delete' actions
    'actions'=>array('admin','delete','index','view','create','update'),
    //'users'=>array('admin'),
      'expression'=>'$user->isAdmin()',
   ),
   array('deny',  // deny all users
    'users'=>array('*'),
     'deniedCallback' => array($this, 'redirecting'),
   ),
  );
 }


public function redirecting(){ $this->redirect(array('/login')); }

No comments:

Post a Comment