diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 29cac1a..95c2d09 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -53,6 +53,7 @@ Yii Framework 2 Change Log - Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue) - Enh: Support for file aliases in console command 'message' (omnilight) - Enh: Sort and Pagination can now create absolute URLs (cebe) +- Chg #1519: `yii\web\User::loginRequired()` now returns the `Response` object instead of exiting the application (qiangxue) - Chg #1586: `QueryBuilder::buildLikeCondition()` will now escape special characters and use percentage characters by default (qiangxue) - Chg #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected (qiangxue) - Chg #1643: Added default value for `Captcha::options` (qiangxue) diff --git a/framework/yii/web/User.php b/framework/yii/web/User.php index b640756..61d68f2 100644 --- a/framework/yii/web/User.php +++ b/framework/yii/web/User.php @@ -320,6 +320,8 @@ class User extends Component * so that the user browser can be redirected to the specified login URL after * calling this method. * After calling this method, the current request processing will be terminated. + * @return Response the redirection response if [[loginUrl]] is set + * @throws AccessDeniedHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set */ public function loginRequired() { @@ -328,8 +330,7 @@ class User extends Component $this->setReturnUrl($request->getUrl()); } if ($this->loginUrl !== null) { - Yii::$app->getResponse()->redirect($this->loginUrl)->send(); - exit(); + return Yii::$app->getResponse()->redirect($this->loginUrl); } else { throw new AccessDeniedHttpException(Yii::t('yii', 'Login Required')); }