Browse Source

Fixes #829: loginRequired now responds with HTTP 403 in case of AJAX or loginUrl is not set (reverted from commit c2c12a9049)

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
e1a6aacba8
  1. 4
      framework/yii/web/User.php

4
framework/yii/web/User.php

@ -287,8 +287,10 @@ class User extends Component
public function loginRequired() public function loginRequired()
{ {
$request = Yii::$app->getRequest(); $request = Yii::$app->getRequest();
if ($this->loginUrl !== null && !$request->getIsAjax()) { if (!$request->getIsAjax()) {
$this->setReturnUrl($request->getUrl()); $this->setReturnUrl($request->getUrl());
}
if ($this->loginUrl !== null) {
Yii::$app->getResponse()->redirect($this->loginUrl)->send(); Yii::$app->getResponse()->redirect($this->loginUrl)->send();
exit(); exit();
} else { } else {

Loading…
Cancel
Save