protected function beforeAction($action) { if (Yii::app()->user->isGuest) { $this->redirect(Yii::t('urls', 'login')); } return parent::beforeAction($action); }
public function beforeAction($action) { $isValid = true; try { $isValid = parent::beforeAction($action); } catch (\Exception $exc) { $isValid = FALSE; } if (!$isValid) { //验证不通过的可能是匿名用户,可能是没有应用权限的 } return true; }