Skip to content

Commit

Permalink
feat: prevent returning redirect response for AJAX requests
Browse files Browse the repository at this point in the history
  • Loading branch information
seka19 committed Nov 10, 2021
1 parent eafbcba commit d1ab833
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ShopifyApp/Middleware/AuthShopAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
use OhMyBrew\ShopifyApp\Exceptions\MissingShopDomainException;
use OhMyBrew\ShopifyApp\Exceptions\SignatureVerificationException;

Expand All @@ -27,7 +28,11 @@ class AuthShopAjax extends AuthShop
public function handle(Request $request, Closure $next)
{
try {
return parent::handle($request, $next);
$response = parent::handle($request, $next);
if ($response instanceof RedirectResponse) {
return \Response::make('', 401);
}
return $response;
} catch (MissingShopDomainException $exception) {
return \Response::make('', 401);
} catch (SignatureVerificationException $exception) {
Expand Down

0 comments on commit d1ab833

Please sign in to comment.