<commit_before><?php

namespace NS\SentinelBundle\Security;

use Symfony\Component\Security\Core\User\UserProviderInterface;
use \Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Doctrine\Common\Persistence\ObjectManager;
use NS\SentinelBundle\Entity\User;

/**
 * Description of UserProvider
 *
 * @author gnat
 */
class UserProvider implements UserProviderInterface
{
    private $em;
    
    public function __construct(ObjectManager $em)
    {
        $this->em = $em;
    }

    public function loadUserByUsername($username) 
    {
        try 
        {
            $user = $this->em->createQuery("SELECT u,a FROM NS\SentinelBundle\Entity\User u LEFT JOIN u.acls a WHERE u.email = :username")
                             ->setParameter('username',$username)
                             ->getSingleResult();
            
            if (null === $user)
                throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));

            $user->setTTL(time()+3600);
            return $user;
        }
        catch(Doctrine\ORM\NonUniqueResultException $e)
        {
            throw new UsernameNotFoundException(sprintf("Username %s is not unique",$username),0, $e);
        }
        catch(\Doctrine\ORM\NoResultException $e)
        {
            throw new UsernameNotFoundException("User not found", 0, $e);
        }
    }

    public function refreshUser(UserInterface $user) 
    {
        if (!$user instanceof User) 
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));

        return (time() > $user->getTTL()) ? $this->loadUserByUsername($user->getUsername()): $user;
    }

    public function supportsClass($class) 
    {
        return $class == 'NS\SentinelBundle\Entity\User';
    }

//put your code here
}<commit_msg>remove commented code<commit_after><?php

namespace NS\SentinelBundle\Security;

use Symfony\Component\Security\Core\User\UserProviderInterface;
use \Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Doctrine\Common\Persistence\ObjectManager;
use NS\SentinelBundle\Entity\User;

/**
 * Description of UserProvider
 *
 * @author gnat
 */
class UserProvider implements UserProviderInterface
{
    private $em;
    
    public function __construct(ObjectManager $em)
    {
        $this->em = $em;
    }

    public function loadUserByUsername($username) 
    {
        try 
        {
            $user = $this->em->createQuery("SELECT u,a FROM NS\SentinelBundle\Entity\User u LEFT JOIN u.acls a WHERE u.email = :username")
                             ->setParameter('username',$username)
                             ->getSingleResult();
            
            if (null === $user)
                throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));

            $user->setTTL(time()+3600);
            return $user;
        }
        catch(Doctrine\ORM\NonUniqueResultException $e)
        {
            throw new UsernameNotFoundException(sprintf("Username %s is not unique",$username),0, $e);
        }
        catch(\Doctrine\ORM\NoResultException $e)
        {
            throw new UsernameNotFoundException("User not found", 0, $e);
        }
    }

    public function refreshUser(UserInterface $user) 
    {
        if (!$user instanceof User) 
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));

        return (time() > $user->getTTL()) ? $this->loadUserByUsername($user->getUsername()): $user;
    }

    public function supportsClass($class) 
    {
        return $class == 'NS\SentinelBundle\Entity\User';
    }
}
{'fraction_non_alphanumeric': 0.11779575328614762, 'fraction_numerical': 0.003033367037411527, 'mean_word_length': 2.617001828153565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1452939', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1076, 'n_words': 228}