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

Commit 8eb0181

Browse files
authoredApr 27, 2022
Simplify the auth flow by removing the full page redirect. (#1075)
* Simplify the auth flow by removing the full page redirect.
1 parent baa6248 commit 8eb0181

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed
 

‎src/Traits/AuthController.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Http\RedirectResponse;
77
use Illuminate\Http\Request;
88
use Illuminate\Support\Facades\Redirect;
9-
use Illuminate\Support\Facades\Session;
109
use Illuminate\Support\Facades\View;
1110
use Osiset\ShopifyApp\Actions\AuthenticateShop;
1211
use Osiset\ShopifyApp\Exceptions\MissingAuthUrlException;
@@ -51,17 +50,12 @@ public function authenticate(Request $request, AuthenticateShop $authShop)
5150
// Show exception, something is wrong
5251
throw new SignatureVerificationException('Invalid HMAC verification');
5352
} elseif ($status === false) {
54-
if (! $result['url']) {
53+
if (!$result['url']) {
5554
throw new MissingAuthUrlException('Missing auth url');
5655
}
5756

58-
return View::make(
59-
'shopify-app::auth.fullpage_redirect',
60-
[
61-
'authUrl' => $result['url'],
62-
'shopDomain' => $shopDomain->toNative(),
63-
]
64-
);
57+
// Just return them straight to the OAUTH flow.
58+
return Redirect::to($result['url']);
6559
} else {
6660
// Go to home route
6761
return Redirect::route(

‎tests/Traits/AuthControllerTest.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ public function testAuthRedirectsToShopifyWhenNoCode(): void
2323
// Run the request
2424
$response = $this->call('post', '/authenticate', ['shop' => 'example.myshopify.com']);
2525

26-
// Check the view
27-
$response->assertViewHas('shopDomain', 'example.myshopify.com');
28-
$response->assertViewHas(
29-
'authUrl',
30-
'https://example.myshopify.com/admin/oauth/authorize?client_id='.Util::getShopifyConfig('api_key').'&scope=read_products%2Cwrite_products&redirect_uri=https%3A%2F%2Flocalhost%2Fauthenticate'
31-
);
26+
// Check the redirect happens and location is set properly in the header.
27+
$response->assertStatus(302);
28+
$response->assertHeader('location', 'https://example.myshopify.com/admin/oauth/authorize?client_id='.Util::getShopifyConfig('api_key').'&scope=read_products%2Cwrite_products&redirect_uri=https%3A%2F%2Flocalhost%2Fauthenticate');
3229
}
3330

3431
public function testAuthAcceptsShopWithCode(): void

0 commit comments

Comments
 (0)