Skip to content

Commit

Permalink
Improvements/subsequent requests (#117)
Browse files Browse the repository at this point in the history
* Subsequent request handling improvements

---------

Co-authored-by: Willem Poortman <[email protected]>
  • Loading branch information
wpoortman and Willem Poortman authored Jul 5, 2023
1 parent 0299dfe commit 5740e9f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Model/Request/MagewireValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ public function validate(RequestInterface $request, ActionInterface $action): vo
$handle = $input['fingerprint']['handle'] ?? null;

if (! $handle || preg_match('/^[a-zA-Z0-9][a-zA-Z\d\-_\.]*$/', $handle) !== 1) {
$message = 'Bad Request';
$this->throwException();
}

$result = $this->resultJsonFactory->create();
$result->setStatusHeader(400);
$request->setParams($input);
}

$result->setData([
'message'=> $message,
'code' => 400
]);
private function throwException($message = 'Bad Request')
{
$result = $this->resultJsonFactory->create();
$result->setStatusHeader(400);

throw new InvalidRequestException($result, [new Phrase($message)]);
}
$result->setData([
'message'=> $message,
'code' => 400
]);

$request->setParams($input);
throw new InvalidRequestException($result, [new Phrase($message)]);
}
}

0 comments on commit 5740e9f

Please sign in to comment.