Skip to content

Commit

Permalink
Merge pull request #32 from shopware/next-39991/fix-registration-url-…
Browse files Browse the repository at this point in the history
…and-create-correct-proof

NEXT-39991 - Fix registration url and create correct proof
  • Loading branch information
shyim authored Jan 16, 2025
2 parents 994f4de + 2bfb874 commit a6912f8
Show file tree
Hide file tree
Showing 2 changed files with 261 additions and 19 deletions.
16 changes: 14 additions & 2 deletions src/Registration/RegistrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function register(RequestInterface $request): ResponseInterface
if ($shop === null) {
$shop = $this->shopRepository->createShopStruct(
$queries['shop-id'],
$this->sanitizeShopUrl($queries['shop-url']),
$queries['shop-url'],
$this->shopSecretGeneratorInterface->generate()
);

Expand All @@ -78,7 +78,6 @@ public function register(RequestInterface $request): ResponseInterface
'shop-url' => $shop->getShopUrl(),
]);


$psrFactory = new Psr17Factory();

$data = [
Expand All @@ -87,6 +86,8 @@ public function register(RequestInterface $request): ResponseInterface
'secret' => $shop->getShopSecret(),
];

$this->fixShopUrlInDatabase($shop);

$response = $psrFactory->createResponse(200);

return $response
Expand Down Expand Up @@ -163,4 +164,15 @@ private function sanitizeShopUrl(string $shopUrl): string
$normalizedPath
);
}

private function fixShopUrlInDatabase(ShopInterface $shop): void
{
$sanitizedShopUrl = $this->sanitizeShopUrl($shop->getShopUrl());


if ($shop->getShopUrl() !== $sanitizedShopUrl) {
$shop->setShopUrl($sanitizedShopUrl);
$this->shopRepository->updateShop($shop);
}
}
}
Loading

0 comments on commit a6912f8

Please sign in to comment.