当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getIdentity方法代码示例

本文整理汇总了PHP中yii\web\User::getIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getIdentity方法的具体用法?PHP User::getIdentity怎么用?PHP User::getIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\web\User的用法示例。


在下文中一共展示了User::getIdentity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getIdentity

 public function getIdentity($autoRenew = true)
 {
     if ($this->_overrideIdentity !== null) {
         return $this->_overrideIdentity;
     }
     return parent::getIdentity($autoRenew);
 }
开发者ID:ExtPoint,项目名称:project-boilerplate,代码行数:7,代码来源:ContextUser.php

示例2: getIdentity

 /**
  * 
  * overwrite 存到session
  */
 public function getIdentity($autoRenew = true)
 {
     if (!Yii::$app->session["_userInfo"]) {
         Yii::$app->session["_userInfo"] = parent::getIdentity($autoRenew);
     }
     return Yii::$app->session["_userInfo"];
 }
开发者ID:rockielin,项目名称:yii2-app-advanced-template,代码行数:11,代码来源:User.php

示例3: matchActionAccess

 /**
  * check the permission, if we rewrite and controller, the controller id and module id is not changed
  * @param \yii\base\Action $action
  * @param \yii\web\User $user
  * @param \yii\web\Request $request
  * @return bool
  */
 public function matchActionAccess($action, $user, $request)
 {
     if ($user->getIsGuest()) {
         return false;
     }
     /** @var \core\auth\Module $authModule */
     $authModule = \Yii::$app->getModule('core_auth');
     foreach ($authModule->getAdmins() as $key => $admin) {
         if ($user->getIdentity()->username == $admin['username']) {
             return true;
         }
     }
     if ($action->controller->module instanceof Application) {
         $key = 'default' . '_' . $action->controller->id . '_' . $action->id;
     } else {
         $key = $action->getUniqueId();
         $key = explode('/', $key);
         array_shift($key);
         $key = implode('_', $key);
     }
     $key = lcfirst(implode('', array_map(function ($k) {
         return ucfirst($k);
     }, explode('-', $key))));
     return $user->can($key, $this->params);
 }
开发者ID:yinheark,项目名称:yincart2,代码行数:32,代码来源:ActionAccessRule.php

示例4: checkSecureAccess

 /**
  * Returns true if $user can edit secure options for concrete entity ($owner).
  * @param User $user
  * @return bool
  */
 public function checkSecureAccess(User $user)
 {
     Yii::trace("Checking secure access to '{$this->owner->className()}'" . PHP_EOL . 'Identifier: ' . VarDumper::dumpAsString($this->owner->getPrimaryKey(true)) . PHP_EOL . "User: {$user->getId()}", __METHOD__);
     if (($identity = $user->getIdentity()) && $identity->isAdmin) {
         return true;
     }
     if (empty($this->secureRoles)) {
         return false;
     }
     foreach ($this->secureRoles as $item) {
         if (!$user->can($item)) {
             return false;
         }
     }
     return true;
 }
开发者ID:yii2-tools,项目名称:yii2-secure-ar,代码行数:21,代码来源:SecureBehavior.php

示例5: getIdentity

 /**
  * @param bool $autoRenew
  * @return null|\app\models\User
  */
 public function getIdentity($autoRenew = true)
 {
     return parent::getIdentity($autoRenew);
 }
开发者ID:remk-wadriga,项目名称:calories-calculating-yii2-project,代码行数:8,代码来源:User.php

示例6: checkAccess

 /**
  * @param array $row
  * @param SecureActiveQueryInterface $query
  * @param User $user
  * @return User
  * @throws \LogicException
  * @SuppressWarnings(PHPMD.ElseExpression)
  */
 protected function checkAccess(array $row, SecureActiveQueryInterface $query, User $user)
 {
     $identifier = ($identity = $user->getIdentity()) ? $identity->username : 0;
     Yii::trace("Checking access to row data for user '{$identifier}'" . PHP_EOL . VarDumper::dumpAsString($row), __METHOD__);
     $secureItemField = $query->getSecureItemAttribute();
     if (!isset($row[$secureItemField])) {
         throw new \LogicException("Row from database should contain secure item field '{$secureItemField}'");
     }
     $permission = $row[$secureItemField];
     if (!is_null($identity) && $identity->isAdmin) {
         $result = true;
     } else {
         $result = $user->can($permission);
     }
     Yii::getLogger()->log(($result ? 'Access granted' : 'Access denied') . " for user '{$identifier}' (" . $permission . ')', $result ? Logger::LEVEL_INFO : Logger::LEVEL_WARNING, __METHOD__);
     return $result;
 }
开发者ID:yii2-tools,项目名称:yii2-secure-ar,代码行数:25,代码来源:SecureFilterBehavior.php


注:本文中的yii\web\User::getIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。