diff --git a/framework/yii/web/User.php b/framework/yii/web/User.php index b1ca8c2..4784063 100644 --- a/framework/yii/web/User.php +++ b/framework/yii/web/User.php @@ -287,10 +287,8 @@ class User extends Component public function loginRequired() { $request = Yii::$app->getRequest(); - if (!$request->getIsAjax()) { + if ($this->loginUrl !== null && !$request->getIsAjax()) { $this->setReturnUrl($request->getUrl()); - } - if ($this->loginUrl !== null) { Yii::$app->getResponse()->redirect($this->loginUrl)->send(); exit(); } else {