Fixed JSON content type issue.

This commit is contained in:
flash 2022-02-27 17:37:27 +00:00
parent a18b3244e9
commit 22bc5f4168

View file

@ -328,7 +328,11 @@ final class SockChatHandler extends Handler {
} }
public function verify($response, $request): array { public function verify($response, $request): array {
if(!$request->isStreamContent()) if($request->isStreamContent())
$authInfo = json_decode((string)$request->getContent());
elseif($request->isJsonContent())
$authInfo = $request->getContent()->getContent(); // maybe change this api lol, this looks silly
else
return ['success' => false, 'reason' => 'request']; return ['success' => false, 'reason' => 'request'];
$userHash = $request->hasHeader('X-SharpChat-Signature') ? $request->getHeaderFirstLine('X-SharpChat-Signature') : ''; $userHash = $request->hasHeader('X-SharpChat-Signature') ? $request->getHeaderFirstLine('X-SharpChat-Signature') : '';
@ -336,8 +340,6 @@ final class SockChatHandler extends Handler {
if(strlen($userHash) !== 64) if(strlen($userHash) !== 64)
return ['success' => false, 'reason' => 'length']; return ['success' => false, 'reason' => 'length'];
$authInfo = json_decode((string)$request->getContent());
if(!isset($authInfo->user_id, $authInfo->token, $authInfo->ip)) if(!isset($authInfo->user_id, $authInfo->token, $authInfo->ip))
return ['success' => false, 'reason' => 'data']; return ['success' => false, 'reason' => 'data'];