public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
if (Yii::app()->user->getId()==null) {
// the URL that the user should be redirected to after login.
app()->user->setReturnUrl(Yii::app()->getRequest()->requestUri);
Yii::app()->getRequest()->redirect('/login');
}
$controller->layout = 'main';
// this method is called before any module controller action is performed
// you may place customized code here
return true;
}
else
return false;
}