![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-customer/Model/Session/Validators/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Customer\Model\Session\Validators; use Magento\Customer\Model\ResourceModel\Customer as ResourceCustomer; use Magento\Customer\Model\ResourceModel\Visitor as ResourceVisitor; use Magento\Framework\Exception\SessionException; use Magento\Framework\Phrase; use Magento\Framework\Session\SessionManagerInterface; use Magento\Framework\Session\ValidatorInterface; use Magento\Framework\Session\Generic; /** * Session Validator */ class CutoffValidator implements ValidatorInterface { /** * @var ResourceCustomer */ private $customerResource; /** * @var ResourceVisitor */ private $visitorResource; /** * @var Generic */ private $visitorSession; /** * Cutoff validator constructor. * * @param ResourceCustomer $customerResource * @param ResourceVisitor $visitorResource * @param Generic $visitorSession */ public function __construct( ResourceCustomer $customerResource, ResourceVisitor $visitorResource, Generic $visitorSession ) { $this->customerResource = $customerResource; $this->visitorResource = $visitorResource; $this->visitorSession = $visitorSession; } /** * Validate session * * @param SessionManagerInterface $session * @return void * @throws SessionException */ public function validate(SessionManagerInterface $session): void { try { $visitor = $this->visitorSession->getVisitorData(); if ($visitor !== null && array_key_exists('customer_id', $visitor) && array_key_exists('visitor_id', $visitor) ) { $cutoff = $this->customerResource->findSessionCutOff((int) $visitor['customer_id']); $sessionCreationTime = $this->visitorResource->fetchCreatedAt((int) $visitor['visitor_id']); if (isset($cutoff, $sessionCreationTime) && $cutoff > $sessionCreationTime) { throw new SessionException( new Phrase('The session has expired, please login again.') ); } } } catch (SessionException $e) { $session->destroy(['clear_storage' => false]); // throw core session exception throw $e; } } }