Browse Source

Renames AccessDeniedHttpException to ForbiddenHttpException in framework, docs, and extension files

tags/2.0.0-beta
Daniel Schmidt 11 years ago
parent
commit
f24454a458
  1. 2
      docs/guide/authorization.md
  2. 4
      extensions/debug/Module.php
  3. 4
      extensions/gii/Module.php
  4. 2
      framework/classes.php
  5. 4
      framework/web/AccessControl.php
  6. 4
      framework/web/User.php

2
docs/guide/authorization.md

@ -248,7 +248,7 @@ public function editArticle($id)
throw new NotFoundHttpException;
}
if (!\Yii::$app->user->checkAccess('edit_article', ['article' => $article])) {
throw new AccessDeniedHttpException;
throw new ForbiddenHttpException;
}
// ...
}

4
extensions/debug/Module.php

@ -10,7 +10,7 @@ namespace yii\debug;
use Yii;
use yii\base\Application;
use yii\web\View;
use yii\web\AccessDeniedHttpException;
use yii\web\ForbiddenHttpException;
/**
* The Yii Debug Module provides the debug toolbar and debugger
@ -80,7 +80,7 @@ class Module extends \yii\base\Module
} elseif ($action->id === 'toolbar') {
return false;
} else {
throw new AccessDeniedHttpException('You are not allowed to access this page.');
throw new ForbiddenHttpException('You are not allowed to access this page.');
}
}

4
extensions/gii/Module.php

@ -8,7 +8,7 @@
namespace yii\gii;
use Yii;
use yii\web\AccessDeniedHttpException;
use yii\web\ForbiddenHttpException;
/**
* This is the main module class for the Gii module.
@ -110,7 +110,7 @@ class Module extends \yii\base\Module
if ($this->checkAccess()) {
return parent::beforeAction($action);
} else {
throw new AccessDeniedHttpException('You are not allowed to access this page.');
throw new ForbiddenHttpException('You are not allowed to access this page.');
}
}

2
framework/classes.php

@ -196,7 +196,7 @@ return [
'yii\validators\ValidationAsset' => YII_PATH . '/validators/ValidationAsset.php',
'yii\validators\Validator' => YII_PATH . '/validators/Validator.php',
'yii\web\AccessControl' => YII_PATH . '/web/AccessControl.php',
'yii\web\AccessDeniedHttpException' => YII_PATH . '/web/AccessDeniedHttpException.php',
'yii\web\ForbiddenHttpException' => YII_PATH . '/web/ForbiddenHttpException.php',
'yii\web\AccessRule' => YII_PATH . '/web/AccessRule.php',
'yii\web\Application' => YII_PATH . '/web/Application.php',
'yii\web\AssetBundle' => YII_PATH . '/web/AssetBundle.php',

4
framework/web/AccessControl.php

@ -130,14 +130,14 @@ class AccessControl extends ActionFilter
* The default implementation will redirect the user to the login page if he is a guest;
* if the user is already logged, a 403 HTTP exception will be thrown.
* @param User $user the current user
* @throws AccessDeniedHttpException if the user is already logged in.
* @throws ForbiddenHttpException if the user is already logged in.
*/
protected function denyAccess($user)
{
if ($user->getIsGuest()) {
$user->loginRequired();
} else {
throw new AccessDeniedHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
}
}
}

4
framework/web/User.php

@ -323,7 +323,7 @@ class User extends Component
* Note that when [[loginUrl]] is set, calling this method will NOT terminate the application execution.
*
* @return Response the redirection response if [[loginUrl]] is set
* @throws AccessDeniedHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set
* @throws ForbiddenHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set
*/
public function loginRequired()
{
@ -334,7 +334,7 @@ class User extends Component
if ($this->loginUrl !== null) {
return Yii::$app->getResponse()->redirect($this->loginUrl);
} else {
throw new AccessDeniedHttpException(Yii::t('yii', 'Login Required'));
throw new ForbiddenHttpException(Yii::t('yii', 'Login Required'));
}
}

Loading…
Cancel
Save