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/cartforge.co/vendor/magento/module-admin-adobe-ims/Service/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/vendor/magento/module-admin-adobe-ims/Service/ImsOrganizationService.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\AdminAdobeIms\Service;

use Magento\AdminAdobeIms\Exception\AdobeImsOrganizationAuthorizationException;
use Magento\Framework\HTTP\Client\CurlFactory;

class ImsOrganizationService
{
    /**
     * @var ImsConfig
     */
    private ImsConfig $adminImsConfig;

    /**
     * @var CurlFactory
     */
    private CurlFactory $curlFactory;

    /**
     * @param ImsConfig $adminImsConfig
     * @param CurlFactory $curlFactory
     */
    public function __construct(
        ImsConfig $adminImsConfig,
        CurlFactory $curlFactory
    ) {
        $this->adminImsConfig = $adminImsConfig;
        $this->curlFactory = $curlFactory;
    }

    /**
     * Check if user is a member of Adobe Organization
     *
     * @param string $access_token
     * @return void
     * @throws AdobeImsOrganizationAuthorizationException
     */
    public function checkOrganizationMembership(string $access_token): void
    {
        $configuredOrganizationId = $this->adminImsConfig->getOrganizationId();

        if ($configuredOrganizationId === '' || !$access_token) {
            throw new AdobeImsOrganizationAuthorizationException(
                __('Can\'t check user membership in organization.')
            );
        }

        try {
            $curl = $this->curlFactory->create();

            $curl->addHeader('Content-Type', 'application/x-www-form-urlencoded');
            $curl->addHeader('cache-control', 'no-cache');
            $curl->addHeader('Authorization', 'Bearer ' . $access_token);

            $orgCheckUrl = $this->adminImsConfig->getOrganizationMembershipUrl($configuredOrganizationId);
            $curl->get($orgCheckUrl);

            if ($curl->getBody() === '') {
                throw new AdobeImsOrganizationAuthorizationException(
                    __('Could not check Organization Membership. Response is empty.')
                );
            }

            $response = $curl->getBody();

            if ($response !== 'true') {
                throw new AdobeImsOrganizationAuthorizationException(
                    __('User is not a member of configured Adobe Organization.')
                );
            }
        } catch (\Exception $exception) {
            throw new AdobeImsOrganizationAuthorizationException(
                __('Organization Membership check can\'t be performed')
            );
        }
    }
}

Spamworldpro Mini