本文整理汇总了PHP中Cake\Controller\Controller::isAuthorized方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::isAuthorized方法的具体用法?PHP Controller::isAuthorized怎么用?PHP Controller::isAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Controller\Controller
的用法示例。
在下文中一共展示了Controller::isAuthorized方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAuthorized
public function isAuthorized($user)
{
$action = $this->request->params['action'];
// The add and index actions are always allowed.
if (in_array($action, ['index', 'add', 'tags', 'view', 'delete', 'edit', 'view_pdf', 'logout'])) {
return true;
}
return parent::isAuthorized($user);
}
示例2: isAuthorized
public function isAuthorized($user)
{
// All registered users can add articles
if ($this->request->action === 'add' or 'search' or 'gear') {
return true;
}
// The owner of an article can edit and delete it
if (in_array($this->request->action, ['edit', 'delete'])) {
$articleId = (int) $this->request->params['pass'][0];
if ($this->Articles->isOwnedBy($articleId, $user['id'])) {
return true;
}
}
return parent::isAuthorized($user);
}
示例3: authorize
/**
* Checks user authorization using a controller callback.
*
* @param array $user Active user data
* @param \Cake\Network\Request $request Request instance.
* @return bool
*/
public function authorize($user, Request $request)
{
return (bool) $this->_Controller->isAuthorized($user);
}