Browse Source

`yii\web\User::loginRequired()` now returns the `Response` object instead of exiting the application

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
fb0c43b30b
  1. 1
      framework/CHANGELOG.md
  2. 5
      framework/yii/web/User.php

1
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)

5
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'));
}

Loading…
Cancel
Save