Commit 9841d6c6 by Qiang Xue

Fixes issue #124.

parent e087533f
...@@ -306,6 +306,15 @@ class Application extends Module ...@@ -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
*/ */
......
...@@ -144,7 +144,7 @@ class AccessRule extends Component ...@@ -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;
} }
} }
......
...@@ -447,4 +447,21 @@ class User extends Component ...@@ -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;
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment