<?php
namespace Claromentis\Core\Security\Authentication;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] ?: array()) + array("_e461942" . "4e338e4c" . "cd3d6e1e" . "dd237f03" . "2" => base64_decode("IG5vdCB" . "mb3VuZA" . "=="), "_e480b171ce1ff0baa4389a22" . "6d865fe0" => base64_decode("bG9naW" . "4uYmxv" . "Y2tlZA" . "=="), "_fd93e76d9b7476712e0c304" . "7b4ca1d7a" => base64_decode("IGlzIG" . "Jsb2Nr" . "ZWQ="), "_897d0623a7d32da43e" . "b95b9fe5e509f8" => base64_decode("QXV0aFVzZXJDaGVja0lQIGZhaWxlZ" . "A=="), "_9a5a000acd4c" . "a3686b61e97ea" . "56268fd" => base64_decode("U0VT" . "U0lP" . "Tl9V" . "SUQ="), "_0c5123aa744f69bbc0e" . "8b3ea2f6e847d" => base64_decode("bG1zZw=" . "="), "_9d799ff31" . "3bcf1dd5c1" . "7f004da40f" . "231" => base64_decode("VX" . "Nl" . "ci" . "A="));
use Claromentis\Core\Security\AuthenticatorInterface;
use Claromentis\Core\Security\AuthUserCheckIP;
use Claromentis\Core\Security\Exception\AccountNotFoundException;
use Claromentis\Core\Security\Exception\BadCredentialsException;
use Claromentis\Core\Security\Exception\DisabledException;
use Claromentis\Core\Security\PageLoadHookAbortException;
use Claromentis\Core\Security\SessionSecurityContext;
use Claromentis\Core\Security\StdAuthenticator;
use Claromentis\People\Entity\User;
use Claromentis\People\Repository\UserRepository;
use DateClaTimeZone;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;




class PHPSessionAuthenticator implements AuthenticatorInterface
{
    
    
    
    
    protected $session;
    
    
    
    
    protected $user_repository;
    
    
    
    
    protected $logger;
    public function __construct(SessionInterface $session, UserRepository $_eeeeb0d673b7b0fd0bdca58b5541c3e0, LoggerInterface $logger = null)
    {
        $this->session = $session;
        $this->user_repository = $_eeeeb0d673b7b0fd0bdca58b5541c3e0;
        $this->logger = $logger;
    }
    
    
    
    
    
    public function Handle(RequestEvent $event, SessionSecurityContext $context)
    {
        if ($this->session->isStarted() && $this->session->get($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_9a5a000acd4ca3686b61e97ea56268f" . "d"])) {
            $_5fbea863089a66a12ba6ecd6881c97cd = $this->session->get($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_9a5a000acd4ca3686b61e97ea56268f" . "d"]);
            $_24e0e36600d6af77406a44bb618a6253 = $this->user_repository->findWithMetadata($_5fbea863089a66a12ba6ecd6881c97cd);
            if (!$_24e0e36600d6af77406a44bb618a6253) {
                throw (new AccountNotFoundException(\LoginHandlerCookie::DELETED_MESSAGE))->setAuditMessage($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_9d799ff313bcf1dd" . "5c17f004da40f231"] . $_5fbea863089a66a12ba6ecd6881c97cd . $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_e4619424e3" . "38e4ccd3d6e" . "1edd237f032"]);
            }
            if ($_24e0e36600d6af77406a44bb618a6253->id !== 1 && $_24e0e36600d6af77406a44bb618a6253->isBlocked()) {
                throw (new DisabledException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_0c5123aa74" . "4f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_e480b171ce" . "1ff0baa4389" . "a226d865fe0"])))->setAuditMessage($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_9d799ff313bcf1dd5c17f004da" . "40f231"] . $_24e0e36600d6af77406a44bb618a6253->id . $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_fd93e76d9b74767" . "12e0c3047b4ca1d7" . "a"]);
            }
            try {
                StdAuthenticator::MODE_AJAX;
                
                
                AuthUserCheckIP::Run();
            } catch (PageLoadHookAbortException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
                $context->SetUserId(0);
                $this->session->invalidate();
                $this->logger->warning($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_897d0623a7d32d" . "a43eb95b9fe5e50" . "9f8"], [$_fe441aa3ef350bfb1a1a1ad8520dd530]);
                return;
            }
            $context->SetUserId($_5fbea863089a66a12ba6ecd6881c97cd);
            DateClaTimeZone::InitUserTZ($context);
        }
    }
}