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

Commit

Permalink
Backport fix for issue #56
Browse files Browse the repository at this point in the history
  • Loading branch information
gnikyt committed Jul 24, 2018
1 parent 7acc855 commit af09780
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/ShopifyApp/Middleware/AuthProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Http\Request;
use OhMyBrew\ShopifyApp\Facades\ShopifyApp;

class AuthProxy
{
Expand Down Expand Up @@ -39,6 +40,9 @@ public function handle(Request $request, Closure $next)
abort(401, 'Invalid proxy signature');
}

// Save shop domain to session
session(['shopify_domain' => ShopifyApp::sanitizeShopDomain(request('shop'))]);

// All good, process proxy request
return $next($request);
}
Expand Down
11 changes: 9 additions & 2 deletions tests/Middleware/AuthProxyMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OhMyBrew\ShopifyApp\Test\Middleware;

use Illuminate\Support\Facades\Input;
use OhMyBrew\ShopifyApp\Facades\ShopifyApp;
use OhMyBrew\ShopifyApp\Middleware\AuthProxy;
use OhMyBrew\ShopifyApp\Test\TestCase;

Expand Down Expand Up @@ -47,13 +48,19 @@ public function testDenysForMissingShop()
public function testRuns()
{
Input::merge($this->queryParams);

// Confirm no shop
$this->assertEquals(null, session('shopify_domain'));
$called = false;
(new AuthProxy())->handle(request(), function ($request) use (&$called) {
// Should be called
$called = true;
// Session should be set by now
$this->assertEquals($this->queryParams['shop'], session('shopify_domain'));
// Shop should be callable
$shop = ShopifyApp::shop();
$this->assertEquals($this->queryParams['shop'], $shop->shopify_domain);
});

// Confirm full run
$this->assertEquals(true, $called);
}

Expand Down

0 comments on commit af09780

Please sign in to comment.