mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-20 21:14:10 +00:00
36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Accounts\Services;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use App\Classes\Exceptions\AccessUnauthorisedException;
|
|
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
|
use App\Classes\ValueObjects\Constants\PlatformType;
|
|
|
|
class CrossAuthenticatesUser
|
|
{
|
|
|
|
/**
|
|
* @param CrossAuthenticationCredentialsObject $object
|
|
* @return false|string
|
|
* @throws AccessUnauthorisedException
|
|
*/
|
|
|
|
public function execute(CrossAuthenticationCredentialsObject $object){
|
|
|
|
if ($object->getPlatform() == PlatformType::EXCHANGE) {
|
|
|
|
$token = $object->getAccessToken();
|
|
|
|
$tokenParts = explode(".", $token);
|
|
$tokenPayload = base64_decode($tokenParts[1]);
|
|
$jwtPayload = json_decode($tokenPayload);
|
|
|
|
$response = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/company/' . $jwtPayload->user->company_id . '/show')->object();
|
|
}
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
} |