This commit is contained in:
glovetleong
2021-09-28 22:07:19 +08:00
parent f385407804
commit 5d34201579
@@ -6,7 +6,6 @@ use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\AccessUnauthorisedException;
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
use App\Classes\ValueObjects\Constants\PlatformType;
use Tymon\JWTAuth\Facades\JWTAuth;
class CrossAuthenticatesUser
{
@@ -21,20 +20,21 @@ class CrossAuthenticatesUser
if ($object->getPlatform() == PlatformType::EXCHANGE) {
$token = $object->getAccessToken();
$tokenParts = explode(".", $token);
$tokenHeader = base64_decode($tokenParts[0]);
$tokenPayload = base64_decode($tokenParts[1]);
$jwtHeader = json_decode($tokenHeader);
$jwtPayload = json_decode($tokenPayload);
dd($jwtPayload);
$response = Http::withToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9leGNoYW5nZS0yLjAudGVzdFwvYXBpXC92MVwvYWNjb3VudFwvYXV0aGVudGljYXRpb25cL2xvZ2luXC9hdHRlbXB0IiwiaWF0IjoxNjMyODAwMzE1LCJleHAiOjk5NjA2MDAzMjE1LCJuYmYiOjE2MzI4MDAzMTUsImp0aSI6Ilo2cGpNMExRbWM5Q1BQQ0YiLCJ1c2VyIjp7ImlkIjo3LCJuYW1lIjoiTGVvbmcgQ2hlZSBTaW9uZyIsImVtYWlsIjoiZ2xvdmV0bGVvbmdAZ21haWwuY29tIiwidHlwZSI6Mywic3RhdHVzIjoyLCJjb21wYW55X2lkIjo5fSwic3ViIjo3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.j_Zr9r6W7gE7zM66NQQk9eHbzHPIz-BYbsVOE7ARukI')->get('http://exchange-2.0.test/api/v1/account/user/list')->object();
$response = Http::withToken($object->getAccessToken())->post('https://dev.exchange.cief-malaysia.com/api/v1/account/authentication/user/show')->object();
dd($response, $object->getAccessToken());
}
if (! auth()->validate(['email' => $object->getEmail(), 'password' => $object->getPassword()])) {
throw new AccessUnauthorisedException('These credentials do not match our records.');
}
return true;
return $response;
}