Skip to content

Commit

Permalink
feature #1512 Changed comment to be more explicit on generated method…
Browse files Browse the repository at this point in the history
… modification + fix generated code
  • Loading branch information
maelanleborgne authored Apr 17, 2024
1 parent c4f8d2c commit 481d6c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Resources/skeleton/webhook/RequestParser.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ protected function getRequestMatcher(): RequestMatcherInterface
*/
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent
{
// Implement your own logic to validate and parse the request, and return a RemoteEvent object.
// TODO: Adapt or replace the content of this method to fit your need.

// Validate the request against $secret.
$authToken = $request->headers->get('X-Authentication-Token');
if (is_null($authToken) || $authToken !== $secret) {
if ($authToken !== $secret) {
throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/fixtures/make-webhook/RemoteServiceRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ protected function getRequestMatcher(): RequestMatcherInterface
*/
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent
{
// Implement your own logic to validate and parse the request, and return a RemoteEvent object.
// TODO: Adapt or replace the content of this method to fit your need.

// Validate the request against $secret.
$authToken = $request->headers->get('X-Authentication-Token');

if (null === $authToken || $authToken !== $secret) {
if ($authToken !== $secret) {
throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.');
}

Expand All @@ -41,7 +40,7 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr
}

// Parse the request payload and return a RemoteEvent object.
$payload = $request->getPayload()->getIterator()->getArrayCopy();
$payload = $request->getPayload()->all();

return new RemoteEvent(
$payload['name'],
Expand Down

0 comments on commit 481d6c6

Please sign in to comment.