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


PHP TokenStorageInterface::isGranted方法代码示例

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


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

示例1: getUserData

 /**
  * Get current user info.
  *
  * @return null|array
  */
 private function getUserData()
 {
     if (null === $this->tokenStorage) {
         return null;
     }
     if ($this->tokenStorage->getToken() && $this->tokenStorage->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $userData = array();
         $user = $this->tokenStorage->getToken()->getUser();
         if (!$user) {
             return null;
         }
         if (method_exists($user, 'getId')) {
             $userData['id'] = $user->getId();
         } else {
             // id is required
             $userData['id'] = $user->getUsername();
         }
         $userData['username'] = $user->getUsername();
         if (method_exists($user, 'getEmail')) {
             $userData['email'] = $user->getEmail();
         }
         return $userData;
     }
     return null;
 }
开发者ID:slayful,项目名称:StaffimRollbarBundle,代码行数:30,代码来源:RollbarReporter.php

示例2: getResourceIfAllowed

 /**
  * Gets the resource if the current user is granted and if the resource exists.
  *
  * @param string $resourceId The resource id
  * @param string $grant      The grant, by default is view
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  *
  * @return Object
  */
 protected function getResourceIfAllowed($resourceId, $grant = 'view')
 {
     $resource = $this->repository->find($resourceId, false);
     if (!$this->context->isGranted($grant, $resource)) {
         throw new AccessDeniedException();
     }
     return $resource;
 }
开发者ID:dasklney,项目名称:kreta,代码行数:18,代码来源:ResourceIfAllowedAnnotationListener.php

示例3: configureOptions

 public function configureOptions(OptionsResolver $resolver)
 {
     if ($this->authorizationChecker instanceof AuthorizationCheckerInterface) {
         if (!$this->tokenStorage->getToken()) {
             return;
         }
         if (!$this->authorizationChecker->isGranted($this->role)) {
             return;
         }
     } else {
         if (!$this->tokenStorage->getToken()) {
             return;
         }
         if (!$this->tokenStorage->isGranted($this->role)) {
             return;
         }
     }
     $resolver->setDefaults(array('csrf_protection' => false));
 }
开发者ID:RubenCox,项目名称:Symfony_Web-Mobile,代码行数:19,代码来源:DisableCSRFExtension.php

示例4: isViewable

 /**
  * isViewable
  *
  * @param mixed $entity
  *
  * @return bool
  */
 public function isViewable($entity)
 {
     $editPermission = $entity instanceof Document ? 'DOCUMENT_EDIT' : 'NODE_EDIT';
     return $this->securityContext->isGranted('VIEW', $entity) && ($this->securityContext->isGranted($editPermission, $entity) || $entity->isEnabled());
 }
开发者ID:DavidG04,项目名称:ErichardDmsBundle,代码行数:12,代码来源:DmsManager.php


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