/** * @return bool * @throws \yii\web\ForbiddenHttpException */ public function beforeRun() { if ($this->needAuthorize && Yii::$app->user->isGuest) { HttpError::the403(); } return parent::beforeRun(); }