Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function refreshUser(UserInterface $user)
 {
     $refreshedUser = $this->ownerManager->findDeveloperBy(array('id' => $user->getId()));
     if (null === $refreshedUser) {
         throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be reloaded.', $user->getId()));
     }
     return $refreshedUser;
 }
 public function refreshUser(UserInterface $user)
 {
     /**
      * @var \FOS\UserBundle\Entity\User $user
      */
     if ($this->isStateless()) {
         throw new UnsupportedUserException();
     }
     if (null === ($reloadedUser = $this->getUserManager()->findUserBy(array('id' => $user->getId())))) {
         throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be reloaded.', $user->getId()));
     }
     return $reloadedUser;
 }
 public function equals(UserInterface $user)
 {
     if ($user instanceof MagentoUser) {
         return $user->getId() === $user->id;
     }
     return $user->getUsername() === $this->email;
 }
 /**
  * {@inheritDoc}
  */
 public function refreshUser(UserInterface $user)
 {
     if (null === ($refreshedUser = $this->repository->findOneByUsername($user->getUsername()))) {
         throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($user->getId())));
     }
     return $refreshedUser;
 }
Beispiel #5
0
 /**
  * 
  * @param string $attribute
  * @param Club $club
  * @param UserInterface $user
  * @return boolean
  */
 protected function isGranted($attribute, $club, $user = null)
 {
     switch ($attribute) {
         case self::VIEW:
             if (!$club->isPrivate()) {
                 return true;
             }
             // make sure there is a user object (i.e. that the user is logged in)
             if (!$user instanceof UserInterface) {
                 return false;
             }
             if (in_array('ROLE_ADMIN', $user->getRoles())) {
                 return true;
             }
             break;
         case self::EDIT:
             // make sure there is a user object (i.e. that the user is logged in)
             if (!$user instanceof UserInterface) {
                 return false;
             }
             foreach ($club->getAdministrators() as $administrator) {
                 if ($administrator->getId() == $user->getId()) {
                     return true;
                 }
             }
             if (in_array('ROLE_ADMIN', $user->getRoles())) {
                 return true;
             }
             return false;
         case self::CREATE:
             break;
     }
     return false;
 }
 /**
  * {@inheritDoc}
  */
 public function isEqualTo(UserInterface $user)
 {
     if ($user instanceof FacebookUser && $user->getId() === $this->getId()) {
         return true;
     }
     return false;
 }
Beispiel #7
0
 /**
  * Refreshes the user for the account interface.
  *
  * It is up to the implementation to decide if the user data should be
  * totally reloaded (e.g. from the database), or if the RZ\Roadiz\Core\Entities\User
  * object can just be merged into some internal array of users / identity
  * map.
  *
  * @param RZ\Roadiz\Core\Entities\User $user
  *
  * @return RZ\Roadiz\Core\Entities\User
  * @throws Symfony\Component\Security\Core\Exception\UnsupportedUserException if the account is not supported
  */
 public function refreshUser(UserInterface $user)
 {
     $refreshUser = $this->em->find('RZ\\Roadiz\\Core\\Entities\\User', (int) $user->getId());
     if ($refreshUser !== null) {
         return $refreshUser;
     } else {
         throw new UnsupportedUserException();
     }
 }
 /**
  *
  * @access public
  * @param  \Symfony\Component\Security\Core\User\UserInterface $user
  * @return \CCDNForum\ForumBundle\Entity\Registry
  */
 public function findOrCreateOneRegistryForUser(UserInterface $user)
 {
     $registry = $this->findOneRegistryForUserById($user->getId());
     if (!$registry) {
         $registry = $this->createRegistry();
         $registry->setOwnedBy($user);
         $this->saveRegistry($registry);
     }
     return $registry;
 }
 public function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $connector = new Connector($user->getUsername(), $token->getCredentials());
     if (!$connector->isSignedIn()) {
         throw new BadCredentialsException();
     }
     $student = $connector->getStudent();
     $user->fromStudent($student);
     $user->setLastConnectionAt(new \DateTime());
     if ($user->getId() == null || $user->getAccount() == null) {
         $user->setAccount(new Account());
     }
     $this->em->persist($user);
     $this->em->flush();
 }
Beispiel #10
0
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof WebserviceUser) {
         return false;
     }
     if ($this->id !== $user->getId()) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
Beispiel #11
0
 /**
  * {@inheritdoc}
  */
 protected function checkAttribute(UserInterface $user, $workflow, $attribute)
 {
     switch ($attribute) {
         case self::EDIT:
         case self::MANAGE_STATUS:
             if ($workflow->getCreator()->getId() === $user->getId()) {
                 return VoterInterface::ACCESS_GRANTED;
             }
             break;
         case self::VIEW:
             if ($projects = $workflow->getProjects()) {
                 foreach ($projects as $project) {
                     if ($project->getUserRole($user) !== null) {
                         return VoterInterface::ACCESS_GRANTED;
                     }
                 }
             }
     }
     return VoterInterface::ACCESS_DENIED;
 }
 /**
  * {@inheritDoc}
  */
 public function connect(UserInterface $user, UserResponseInterface $response)
 {
     $username = $response->getUsername();
     $service = $response->getResourceOwner()->getName();
     $setter = 'set' . ucfirst($service);
     $setter_id = $setter . 'Id';
     $setter_token = $setter . 'AccessToken';
     $setter_username = $setter . 'Username';
     $existingUser = $this->userManager->findUserBy(array("{$service}Id" => $username));
     if ($existingUser instanceof UserInterface && $existingUser->getId() != $user->getId()) {
         throw new AlreadyLinkedAccount();
         $previousUser->{$setter_id}(null);
         $previousUser->{$setter_token}(null);
         $this->userManager->updateUser($previousUser);
     }
     $screenName = $response->getNickname();
     $user->{$setter_id}($username);
     $user->{$setter_token}($response->getAccessToken());
     $user->{$setter_username}($screenName);
     if ($service === 'facebook') {
         $this->setFacebookData($user, $response->getResponse());
     }
     $this->userManager->updateUser($user);
 }
Beispiel #13
0
 public function isEqualTo(UserInterface $user)
 {
     if (!$this->isAuthenticated()) {
         return false;
     }
     /* @var $user User */
     if (!$user->isAuthenticated()) {
         return false;
     }
     return $this->getId() == $user->getId();
 }
Beispiel #14
0
 /**
  * Method to find all groups of a user
  *
  * @param \Symfony\Component\Security\Core\User\UserInterface $user
  * @return type
  */
 protected function getUserGroups(UserInterface $user)
 {
     return $this->entityManager->getRepository('OpitOpitHrmUserBundle:Groups')->findUserGroupsArray($user->getId());
 }
Beispiel #15
0
 public function isEqualTo(UserInterface $user)
 {
     return $this->id === $user->getId();
 }
 public function getNewPaymentRequestsQuery(UserInterface $user)
 {
     $className = ucfirst($user->getType()) . 'PaymentRequest';
     return $this->getEntityManager()->createQueryBuilder()->select('pr')->from("CivixCoreBundle:Poll\\Question\\{$className}", 'pr')->where('pr.publishedAt IS NULL')->andWhere('pr.user = :userId')->setParameter('userId', $user->getId())->orderBy('pr.createdAt', 'DESC')->getQuery();
 }
 public function refreshUser(UserInterface $user)
 {
     return $this->find($user->getId());
 }
 /**
  *
  * @access public
  * @return \CCDNUser\AdminBundle\Component\Crumbs\Factory\CrumbTrail
  */
 public function addAccountShow(UserInterface $user)
 {
     return $this->addMemberIndex()->add(array('label' => 'crumbs.account.show', 'params' => array('%name%' => $user->getUsername())), array('route' => 'ccdn_user_admin_account_show', 'params' => array('userId' => $user->getId())));
 }
Beispiel #19
0
 /**
  * @param UserInterface $user
  * @return bool
  */
 public function hasVoted(UserInterface $user)
 {
     /** @var Recipient $approval */
     foreach ($this->recipients as $approval) {
         if ($approval->getRecipient()->getId() === $user->getId()) {
             return !($approval->getAnswer() === null);
         }
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function refreshUser(UserInterface $user)
 {
     /** @var EntityManager $doctrine */
     $doctrine = $this->doctrine->getManager();
     return $doctrine->getRepository($this->userClass)->findOneById($user->getId());
 }
 public function getFreeModulesForUserQuery(UserInterface $user)
 {
     return $this->createQueryBuilder('module')->leftJoin('module.modulesUser mu WITH mu.user = :userId', false)->where('mu IS NULL')->setParameter('userId', $user->getId())->orderBy('module.title', 'ASC');
 }
Beispiel #22
0
 /**
  * @param UserInterface $user
  *
  * @return bool
  */
 public function isEqualTo(UserInterface $user)
 {
     if ($user->getRoles() !== $this->getRoles()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     if ($this->id !== $user->getId()) {
         return false;
     }
     return true;
 }
Beispiel #23
0
 public function equals(UserInterface $user)
 {
     return $user->getId() === $this->getId();
 }
Beispiel #24
0
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof RedmineUser) {
         return false;
     }
     return $user->getId() == $this->getId();
 }
 /**
  * {@inheritdoc}
  */
 public function refreshUser(UserInterface $securityUser)
 {
     return $this->loadUserById($securityUser->getId());
 }
Beispiel #26
0
 /**
  * Adds a condition excluding user from the list
  *
  * @param QueryBuilder  $queryBuilder
  * @param UserInterface $user
  */
 protected function excludeUser(QueryBuilder $queryBuilder, UserInterface $user)
 {
     $queryBuilder->andWhere('users.id != :userId');
     $queryBuilder->setParameter('userId', $user->getId());
 }
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof self) {
         return false;
     }
     if ($this->id !== $user->getId()) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->salt !== $user->getSalt()) {
         return false;
     }
     return true;
 }
 public function getPublishedQuestionQuery(UserInterface $user, $questionClass)
 {
     return $this->getEntityManager()->createQueryBuilder()->select('p')->from($questionClass, 'p')->where('p.publishedAt IS NOT NULL')->andWhere('p.user = :userId')->setParameter('userId', $user->getId())->orderBy('p.createdAt', 'DESC')->getQuery();
 }
Beispiel #29
0
 /**
  * The equality comparison should neither be done by referential equality
  * nor by comparing identities (i.e. getId() === getId()).
  *
  * However, you do not need to compare every attribute, but only those that
  * are relevant for assessing whether re-authentication is required.
  *
  * Also implementation should consider that $user instance may implement
  * the extended user interface `AdvancedUserInterface`.
  *
  * @param UserInterface $user
  *
  * @return bool
  */
 public function isEqualTo(UserInterface $user)
 {
     if ((int) $this->getId() === $user->getId()) {
         return true;
     }
     return false;
 }
 /**
  *
  * @access public
  * @param  \Doctrine\Common\Collections\ArrayCollection        $subscriptions
  * @param  \Symfony\Component\Security\Core\User\UserInterface $exceptUser
  * @return \CCDNForum\ForumBundle\Manager\ManagerInterface
  */
 public function markTheseAsUnread($subscriptions, UserInterface $exceptUser)
 {
     foreach ($subscriptions as $subscription) {
         if ($subscription->getOwnedBy()) {
             if ($subscription->getOwnedBy()->getId() != $exceptUser->getId()) {
                 $subscription->setRead(false);
                 $this->persist($subscription);
             }
         }
     }
     $this->flush();
 }