Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Remove "token" from the query string of the target URL #779

Merged
merged 2 commits into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/ShopifyApp/Traits/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
use Osiset\ShopifyApp\Actions\AuthenticateShop;
use Osiset\ShopifyApp\Exceptions\MissingAuthUrlException;
use Osiset\ShopifyApp\Exceptions\SignatureVerificationException;
use function Osiset\ShopifyApp\getShopifyConfig;
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
use function Osiset\ShopifyApp\getShopifyConfig;
use function Osiset\ShopifyApp\parseQueryString;

/**
* Responsible for authenticating the shop.
Expand Down Expand Up @@ -62,11 +63,25 @@ public function authenticate(Request $request, AuthenticateShop $authShop)
*/
public function token(Request $request)
{
$target = $request->query('target');

$query = parse_url($target, PHP_URL_QUERY);

if ($query) {
// remove "token" from the target's query string
$params = parseQueryString($query);
unset($params['token']);

$cleanTarget = trim(explode('?', $target)[0] . '?' . http_build_query($params), '?');
} else {
$cleanTarget = $target;
}

return View::make(
'shopify-app::auth.token',
[
'shopDomain' => ShopDomain::fromNative($request->query('shop'))->toNative(),
'target' => $request->query('target'),
'target' => $cleanTarget,
]
);
}
Expand Down