public function findUserByForgetPasswordToken($token)
    {
        try {
            $builder = $this->createQueryBuilder('u');

            return $builder->where($builder->expr()->eq('u.forgetPasswordToken', ':token'))
                ->andWhere($builder->expr()->isNotNull('u.forgetPasswordExpired'))
                ->andWhere('u.forgetPasswordExpired >= :today')
                ->setParameter('token', $token)
                ->setParameter('today', new \DateTime(), Type::DATETIME)
                ->getQuery()
                ->getSingleResult();

        } catch (NoResultException $ex) {
            // This means that nothing was found this thrown by the getSingleResult method
            return null;
        } catch (NonUniqueResultException $ex) {
            // this means that there was more then one result found and we have duplicate tokens in our database.
            // Look up the code for the error message in the logs
            throw new ProgrammerException('Duplicate Forget Password Token was found.', ProgrammerException::FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE);
        }
    }
public function findUserByForgetPasswordToken($token)
    {
        try {
            $builder = $this->createQueryBuilder('u');

            return $builder->where($builder->expr()->eq('u.forgetPasswordToken', ':token'))
                ->andWhere($builder->expr()->isNotNull('u.forgetPasswordExpired'))
                ->andWhere('u.forgetPasswordExpired >= :today')
                ->setParameter('token', $token)
                ->setParameter('today', new \DateTime(), Type::DATETIME)
                ->getQuery()
                ->getSingleResult();

        } catch (NoResultException $ex) {
            // This means that nothing was found this thrown by the getSingleResult method
            return null;
        } catch (NonUniqueResultException $ex) {
            // this means that there was more then one result found and we have duplicate tokens in our database.
            // Look up the code for the error message in the logs
            throw new ProgrammerException('Duplicate Forget Password Token was found.', ProgrammerException::FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE);
        }
    }
public function findUserByForgetPasswordToken ( $ token ) { try { $ builder = $ this -> createQueryBuilder ( 'u' ) ; return $ builder -> where ( $ builder -> expr ( ) -> eq ( 'u.forgetPasswordToken' , ':token' ) ) -> andWhere ( $ builder -> expr ( ) -> isNotNull ( 'u.forgetPasswordExpired' ) ) -> andWhere ( 'u.forgetPasswordExpired >= :today' ) -> setParameter ( 'token' , $ token ) -> setParameter ( 'today' , new \ DateTime ( ) , Type :: DATETIME ) -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ ex ) { // This means that nothing was found this thrown by the getSingleResult method return null ; } catch ( NonUniqueResultException $ ex ) { // this means that there was more then one result found and we have duplicate tokens in our database. // Look up the code for the error message in the logs throw new ProgrammerException ( 'Duplicate Forget Password Token was found.' , ProgrammerException :: FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE ) ; } }
Returns a user with the right password token.
If multiple tokens are found in the db a programmer exception is thrown with a specific code.

@param $token
@return null|BaseUser
@throws ProgrammerException
Returns a user with the right password token . If multiple tokens are found in the db a programmer exception is thrown with a specific code .