<commit_before><?php

namespace TBN\UserBundle\Handler;

// "use" statements here
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\JsonResponse;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use TBN\MainBundle\Site\SiteManager;

class AuthenticationHandler implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface
{

    protected $translator;
    protected $router;
    protected $session;
    protected $site_manager;

    public function __construct($translator, $router, $session, SiteManager $site_manager)
    {
        $this->translator = $translator;
        $this->router = $router;
        $this->session = $session;
        $this->site_manager = $site_manager;
    }

    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        if ($request->isXmlHttpRequest()) {
            $result = ['success' => true];
            return new JsonResponse($result);
        } else {

            if (($targetPath = $request->getSession()->get('_security.target_path'))) {
                $url = $targetPath;
            } else {

                $key = '_security.main.target_path'; #where "main" is your firewall name

                //check if the referer session key has been set
                if ($this->session->has($key)) {
                    //set the url based on the link they were trying to access before being authenticated
                    $url = $this->session->get($key);

                    //remove the session key
                    $this->session->remove($key);
                } else {
                    $user = $token->getUser();<commit_msg>FIx key pour target path<commit_after><?php

namespace TBN\UserBundle\Handler;

use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\JsonResponse;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use TBN\MainBundle\Site\SiteManager;

class AuthenticationHandler implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface
{

    protected $translator;
    protected $router;
    protected $session;
    protected $site_manager;

    public function __construct($translator, $router, $session, SiteManager $site_manager)
    {
        $this->translator = $translator;
        $this->router = $router;
        $this->session = $session;
        $this->site_manager = $site_manager;
    }

    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        if ($request->isXmlHttpRequest()) {
            $result = ['success' => true];
            return new JsonResponse($result);
        } else {
            $key = '_security.main.target_path'; #where "main" is your firewall name

            if (($targetPath = $request->getSession()->get($key))) {
                $url = $targetPath;
            } else {

                //check if the referer session key has been set
                if ($this->session->has($key)) {
                    //set the url based on the link they were trying to access before being authenticated
                    $url = $this->session->get($key);

                    //remove the session key
                    $this->session->remove($key);
                } else {
                    $user = $token->getUser();
{'fraction_non_alphanumeric': 0.1035696329813977, 'fraction_numerical': 0.0, 'mean_word_length': 2.837029893924783, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '6642084', 'n_tokens_mistral': 997, 'n_tokens_neox': 962, 'n_words': 230}