Spamworldpro Mini Shell
Spamworldpro


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-two-factor-auth/Observer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-two-factor-auth/Observer/AdminUserSaveAfter.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\TwoFactorAuth\Observer;

use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\TwoFactorAuth\Api\UserConfigManagerInterface;

/**
 * Save tfa providers information in user entity
 */
class AdminUserSaveAfter implements ObserverInterface
{
    /**
     * @var UserConfigManagerInterface
     */
    private $userConfigManager;

    /**
     * @var AuthorizationInterface
     */
    private $authorization;

    /**
     * @param UserConfigManagerInterface $userConfigManager
     * @param AuthorizationInterface $authorization
     */
    public function __construct(
        UserConfigManagerInterface $userConfigManager,
        AuthorizationInterface $authorization
    ) {
        $this->userConfigManager = $userConfigManager;
        $this->authorization = $authorization;
    }

    /**
     * @inheritDoc
     */
    public function execute(Observer $observer)
    {
        if ($this->authorization->isAllowed('Magento_TwoFactorAuth::tfa')) {
            $user = $observer->getEvent()->getObject();
            $data = $user->getData();

            if (isset($data['tfa_providers'])) {
                if (!is_array($data['tfa_providers'])) {
                    $data['tfa_providers'] = [];
                }
                $this->userConfigManager->setProvidersCodes((int) $user->getId(), $data['tfa_providers']);
            }
        }
    }
}

Spamworldpro Mini