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

Commit

Permalink
Remove "token" from the query string of the target URL (#779)
Browse files Browse the repository at this point in the history
* Remove "token" from the query string of the target URL

* Use a cleaner method of setting the new target
  • Loading branch information
squatto authored May 7, 2021
1 parent 849337d commit ba1d469
Showing 1 changed file with 17 additions and 2 deletions.
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

0 comments on commit ba1d469

Please sign in to comment.