Created
May 23, 2014 23:21
-
-
Save juizmill/061ce39020cb441d42b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Application\Entity\Repository; | |
| use Application\Entity\Usuario; | |
| use Doctrine\ORM\EntityRepository; | |
| class UsuarioRepository extends EntityRepository | |
| { | |
| public function findByLoginAndPassword(Usuario $usuario, $login, $password) | |
| { | |
| /** | |
| * @var $userLogin \Application\Entity\Usuario | |
| */ | |
| $userLogin = $this->createQueryBuilder('u') | |
| ->where('u.login = :a1') | |
| ->setParameter('a1', $login)->getQuery()->getOneOrNullResult(); | |
| if(!is_null($userLogin)){ | |
| $usuario->setSalt($userLogin->getSalt()); | |
| if($usuario->encryptPassword($password) == $userLogin->getPassword()){ | |
| return $userLogin; | |
| } | |
| } | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment