/** * @inheritdoc */ public function init() { if ($this->entity) { $this->rules = array_merge($this->entity); } parent::init(); }
public function init() { $rule = ['allow' => true, 'matchCallback' => function ($rule, $action) { return RoleManager::checkAccess($action); }]; $this->rules[] = \Yii::createObject(array_merge($this->ruleConfig, $rule)); parent::init(); }
/** * @see \yii\filters\AccessControl::init() */ public function init() { parent::init(); //非正式环境下,每次请求都要对当前页面的权限进行检查 if (!YII_ENV_PROD) { $this->checkAuthItem(); } }
/** * Initializes the [[rules]] array by instantiating rule objects from configurations. */ public function init() { parent::init(); $this->user = Instance::ensure($this->user, User::className()); foreach ($this->rules as $i => $rule) { if (is_array($rule)) { $this->rules[$i] = Yii::createObject(array_merge($this->ruleConfig, $rule)); } } }
public function init() { parent::init(); if ($this->user->isGuest) { return true; } if (!$this->Privilege()) { die('您没有权限访问这个页面!'); } }
public function init() { $this->user = Instance::ensure($this->user, User::className()); $rolesObject = Yii::$app->authManager->getRolesByUser($this->user->id); if (!empty($rolesObject)) { foreach ($rolesObject as $roles => $object) { foreach ($object->data as $route) { $this->_actions[] = $route; } } } $this->rules = [['actions' => $this->_actions, 'allow' => true]]; parent::init(); }
/** * @inheritdoc */ public function init() { parent::init(); if (!$this->denyMessage && !Yii::$app->user->isGuest) { $this->denyMessage = Yii::t('user', 'You have no rights to perform this action'); } else { if (!$this->denyMessage && Yii::$app->user->isGuest) { $this->denyMessage = Yii::t('user', 'Need authorization to perform this action'); } } $this->denyCallback = function ($rule, $action) { if ($this->denyMessage) { /* @var $systemAlert Alert */ $systemAlert = Yii::$app->systemAlert; $systemAlert->setMessage(Alert::DANGER, $this->denyMessage); } if (Yii::$app->user->isGuest) { Yii::$app->user->loginRequired(); } else { return false; } }; }
/** * Initializes the [[rules]] array by instantiating rule objects from configurations. */ public function init() { parent::init(); }
/** * Set custom ruleConfig */ public function init() { $this->ruleConfig = ['class' => 'frontend\\libraries\\filters\\AccessRule']; parent::init(); }