Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Richtermeister committed Jul 29, 2018
2 parents 2e3c47e + 6bc0e50 commit d9eca07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Controller/OAuthController.php
Expand Up @@ -131,9 +131,10 @@ public function verify(Request $request)
$hmac = $request->get('hmac');

// todo validate store name
// todo leverage options resolver?
if (!$authCode || !$storeName) {
throw new BadRequestHttpException('Request is missing required parameters: "code", "shop".');
if (!$authCode || !$storeName || !$nonce || !$hmac) {
throw new BadRequestHttpException('Request is missing one or more of required parameters: "code", "shop", "state", "hmac".');
}

if (!$this->hmacSignature->isValid($hmac, $request->query->all())) {
Expand All @@ -151,6 +152,7 @@ public function verify(Request $request)
],
];

// todo this can fail - 400
$response = $this->client->request('POST', 'https://' . $storeName . '/admin/oauth/access_token', $params);
$responseJson = \GuzzleHttp\json_decode($response->getBody(), true);

Expand Down
3 changes: 3 additions & 0 deletions src/Service/WebhookCreator.php
Expand Up @@ -44,6 +44,9 @@ public function createWebhooks(string $storeName, array $topics)
'topic' => $topic,
], UrlGeneratorInterface::ABSOLUTE_URL);

// endpoint HAS to be https
$endpoint = str_replace("http://", "https://", $endpoint);

$webhook = GenericResource::create([
'topic' => $topic,
'address' => $endpoint,
Expand Down

0 comments on commit d9eca07

Please sign in to comment.