Browse Source

Fixes issue #124.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
9841d6c639
  1. 9
      framework/base/Application.php
  2. 2
      framework/web/AccessRule.php
  3. 17
      framework/web/User.php

9
framework/base/Application.php

@ -306,6 +306,15 @@ class Application extends Module
} }
/** /**
* @return null|Component
* @todo
*/
public function getAuthManager()
{
return $this->getComponent('auth');
}
/**
* Registers the core application components. * Registers the core application components.
* @see setComponents * @see setComponents
*/ */

2
framework/web/AccessRule.php

@ -144,7 +144,7 @@ class AccessRule extends Component
return true; return true;
} elseif ($role === '@' && !$user->getIsGuest()) { } elseif ($role === '@' && !$user->getIsGuest()) {
return true; return true;
} elseif ($user->hasAccess($role)) { } elseif ($user->checkAccess($role)) {
return true; return true;
} }
} }

17
framework/web/User.php

@ -447,4 +447,21 @@ class User extends Component
} }
} }
} }
/**
* Checks whether the user has access to the specified operation.
* @param $operator
* @param array $params
* @return bool
* @todo
*/
public function checkAccess($operation, $params = array())
{
$auth = Yii::$app->getAuthManager();
if ($auth !== null) {
return $auth->checkAccess($this->getId(), $operation, $params);
} else {
return true;
}
}
} }

Loading…
Cancel
Save