ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Plugin\Security\Model\AdminSessionsManager;
use Amasty\AdminActionsLog\Api\ActiveSessionRepositoryInterface;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\Exception\NoSuchEntityException;
class AddAdminSessionInfoId
{
/**
* @var ActiveSessionRepositoryInterface
*/
private $activeSessionRepository;
/**
* @var Session
*/
private $authSession;
public function __construct(
ActiveSessionRepositoryInterface $activeSessionRepository,
Session $authSession
) {
$this->activeSessionRepository = $activeSessionRepository;
$this->authSession = $authSession;
}
public function afterProcessLogin(): void
{
$sessionId = $this->authSession->getSessionId();
$adminSessionInfoId = $this->authSession->getAdminSessionInfoId();
if (!empty($sessionId) && $adminSessionInfoId) {
try {
$activeSessionModel = $this->activeSessionRepository->getBySessionId($sessionId);
} catch (NoSuchEntityException $exception) {
return;
}
$activeSessionModel->setAdminSessionInfoId((int)$adminSessionInfoId);
$this->activeSessionRepository->save($activeSessionModel);
}
}
}
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Plugin\Security\Model\AdminSessionsManager;
use Amasty\AdminActionsLog\Model\ActiveSession\ResourceModel\ActiveSession as ActiveSessionResource;
use Magento\Backend\Model\Auth\Session;
use Magento\Security\Model\AdminSessionInfo;
use Magento\Security\Model\AdminSessionsManager;
use Psr\Log\LoggerInterface;
class UpdateAdminSessionInfoId
{
/**
* @var ActiveSessionResource
*/
private $activeSessionResource;
/**
* @var Session
*/
private $authSession;
/**
* @var LoggerInterface
*/
private $logger;
/**
* Flag to mark when sessions validation has been passed
* to prevent unnecessary queries.
*
* @var bool
*/
private $isValid = false;
public function __construct(
ActiveSessionResource $activeSessionResource,
Session $authSession,
LoggerInterface $logger
) {
$this->activeSessionResource = $activeSessionResource;
$this->authSession = $authSession;
$this->logger = $logger;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetCurrentSession(
AdminSessionsManager $subject,
AdminSessionInfo $result
): AdminSessionInfo {
if (!$this->isValid) {
$adminSessionInfoId = (int)$result->getId();
if (!empty($this->authSession->getSessionId())
&& $adminSessionInfoId
&& ($user = $this->authSession->getUser())
) {
$userId = (int)$user->getId();
try {
$this->activeSessionResource->updateIfSessionInvalid($userId, $adminSessionInfoId);
} catch (\Exception $e) {
$this->logger->critical($e);
}
}
$this->isValid = true;
}
return $result;
}
}