mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-25 07:24:21 +00:00
44 lines
1.4 KiB
PHP
44 lines
1.4 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) {
|
|
|
|
// $headers = [
|
|
// 'Content-Type' => 'application/json',
|
|
// 'Authorization' => 'Bearer ' . $object->getAccessToken(),
|
|
// ];
|
|
// $client = new \GuzzleHttp\Client(['headers' => $headers]);
|
|
|
|
// $response = $client->get('http://exchange-2.0.test/api/v1/account/user/list');
|
|
|
|
$response = Http::withToken($object->getAccessToken())->get('http://shipping-portal.test/api/v1/account/user/list')->object();
|
|
dd($response);
|
|
|
|
}
|
|
|
|
if (! auth()->validate(['email' => $object->getEmail(), 'password' => $object->getPassword()])) {
|
|
throw new AccessUnauthorisedException('These credentials do not match our records.');
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |