コード例 #1
0
 /**
  * Loads the user for the given username.
  *
  * This method must throw UsernameNotFoundException if the user is not
  * found.
  *
  * @param string $username the consultants username
  *
  * @return \Symfony\Component\Security\Core\User\UserInterface
  *
  * @see \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
  *
  * @throws \Symfony\Component\Security\Core\Exception\UsernameNotFoundException if the user is not found
  */
 public function loadUserByUsername($username)
 {
     if (!$this->queryField) {
         return false;
     }
     $user = $this->documentModel->getRepository()->findOneBy(array($this->queryField => $username));
     return $user ? $user : false;
 }
コード例 #2
0
 /**
  * Finds a contract based on the provided ApiKey.
  *
  * @param string $apiKey key from airlock
  *
  * @return string
  */
 public function getUsernameForApiKey($apiKey)
 {
     $contractId = '';
     /** @var \GravitonDyn\ContractBundle\Document\Contract $contract */
     $contract = $this->documentModel->getRepository()->findOneBy(array('number' => $apiKey));
     if ($contract instanceof Contract) {
         $contractId = $contract->getId();
     }
     return $contractId;
 }