/** * 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; }
/** * Loads the user for the given username. * * This method must throw UsernameNotFoundException if the user is not * found. * * @param string $contractId contract id we need a username for * * @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($contractId) { // TODO [lapistano] to what is the contract to be mapped against?? /** @var \GravitonDyn\ContractBundle\Document\Contract $contracts */ $contract = $this->documentModel->find($contractId); if ($contract instanceof Contract) { // TODO [lapistano]: map the found contract to whatever ... return new SecurityContract($contract, $this->getContractRoles($contract)); } throw new UsernameNotFoundException(); }