本文整理汇总了PHP中App\Controller\AppController::isAuthorized方法的典型用法代码示例。如果您正苦于以下问题:PHP AppController::isAuthorized方法的具体用法?PHP AppController::isAuthorized怎么用?PHP AppController::isAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Controller\AppController
的用法示例。
在下文中一共展示了AppController::isAuthorized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAuthorized
public function isAuthorized($user)
{
if ($this->request->action === 'index') {
return true;
}
return parent::isAuthorized($user);
}
示例2: isAuthorized
public function isAuthorized($user)
{
if (in_array($this->request->action, ['addComment'])) {
return true;
}
return parent::isAuthorized($user);
}
示例3: isAuthorized
public function isAuthorized($user)
{
if ($user['role'] != 'admin') {
return false;
}
return parent::isAuthorized($user);
}
示例4: isAuthorized
public function isAuthorized($user)
{
// All registered users can add projects and view the index.
if (in_array($this->request->action, ['add', 'index'])) {
return true;
}
// The owner of an project can edit and delete it.
if (in_array($this->request->action, ['view', 'edit', 'delete'])) {
$projectId = (int) $this->request->params['pass'][0];
if ($this->Projects->isOwnedBy($projectId, $user['id'])) {
return true;
}
}
$ProjectsUsers = TableRegistry::get('ProjectsUsers');
// Check from the ProjectsUsers table if the person trying to access
// is a moderator of that project.
if (in_array($this->request->action, ['view'])) {
$projectId = (int) $this->request->params['pass'][0];
if ($ProjectsUsers->isModeratedBy($projectId, $user['id'])) {
return true;
}
}
// Check from the ProjectsUsers table if the person trying to access
// is assigned to that project.
if (in_array($this->request->action, ['view'])) {
$projectId = (int) $this->request->params['pass'][0];
if ($ProjectsUsers->isAssignedTo($projectId, $user['id'])) {
return true;
}
}
return parent::isAuthorized($user);
}
示例5: isAuthorized
public function isAuthorized($user)
{
if (in_array($this->request->action, ['weeklyBets', 'add'])) {
return true;
}
return parent::isAuthorized($user);
}
示例6: isAuthorized
public function isAuthorized($user = null)
{
//DTR: Por defecto no se autoriza el acceso al usuario/rol/controlador/accion.
$res = false;
//DTR: Si se quiere controlar en herencia, reusar el metodo padre...
//...pero solo en herencia de "AppController"
$res = parent::isAuthorized($user);
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' usuario= '.var_export( $user, true));
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' _SESSION= '.var_export( $_SESSION, true));
//Cualquiera de las acciones de este controlador se permiten SOLO para
//los usuarios de rol administrador, y eso se controla ya en
//"AppController".
if (!$res) {
$rol = $user['rol'];
$controlador = $this->request->params['controller'];
$accion = $this->request->params['action'];
//Permite el aceso al usuario 'sysadmin
if ($user['rol'] === 'sysadmin') {
$res = true;
}
//Permite el acceso al método 'cambiarRol' al usuario 'sysadmin' únicamente
if ($user['nombre'] === 'sysadmin' && $accion === 'cambiarRol') {
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' rol= '.$rol.', acceso= '.$controlador.'::'.$accion.', res= '.var_export( $res, true));
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' _SESSION= '.var_export( $_SESSION, true));
$res = true;
}
}
if (isset($user) && $this->request->params['action'] === 'logout') {
$res = true;
}
return $res;
}
示例7: isAuthorized
public function isAuthorized($user)
{
if (in_array($this->request->action, ['addPost', 'indexPost', 'viewPost', 'deletePost'])) {
return true;
}
return parent::isAuthorized($user);
}
示例8: isAuthorized
public function isAuthorized($user)
{
if (in_array($this->request->action, ['today', 'view', 'edit'])) {
return true;
}
return parent::isAuthorized($user);
}
示例9: isAuthorized
public function isAuthorized($user = null)
{
if (in_array($this->request->action, ['index', 'view', 'logout'])) {
return true;
}
return parent::isAuthorized($user);
}
示例10: isAuthorized
/**
* isAuthorized method
*
* @param array $user User
* @return bool
*/
public function isAuthorized($user)
{
if (parent::isAuthorized($user)) {
return true;
}
$accessible = ['changePassword', 'updateContact'];
return in_array($this->request->action, $accessible);
}
示例11: isAuthorized
public function isAuthorized($user)
{
if (isset($user['role']) and $user['role'] === 'user') {
if (in_array($this->request->action, ['home', 'view', 'logout'])) {
return true;
}
}
return parent::isAuthorized($user);
}
示例12: isAuthorized
public function isAuthorized($user)
{
if (in_array($this->request->action, ['add', 'edit', 'delete'])) {
if ($this->Auth->user('role') === 'admin') {
return true;
}
}
return parent::isAuthorized($user);
}
示例13: isAuthorized
/**
* Check if user is authorized
* Authorization restricted by ownership should use the method check() within Ownership Component
*
* @param array $user
* @return boolean
*/
public function isAuthorized($user)
{
if (parent::isAuthorized($user)) {
$action = $this->request->params['action'];
// Allowing actions for logged users (excluding admin actions)
return true;
}
return false;
}
示例14: isAuthorized
public function isAuthorized($user)
{
$action = $this->request->params['action'];
// The add and dashboard actions are always allowed.
if (in_array($action, ['popup', 'popupadd'])) {
return true;
}
return parent::isAuthorized($user);
}
示例15: isAuthorized
public function isAuthorized($user = null)
{
if (isset($user['role']) && $user['role'] !== $this->roles['Admin']) {
if ($this->request->action === 'view') {
return false;
}
}
// Par défaut n'autorise pas
return parent::isAuthorized($user);
}