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

Commit

Permalink
Attempt to force Laravel to expire the session on close, so shops do …
Browse files Browse the repository at this point in the history
…not get logged out early for isse #60
  • Loading branch information
gnikyt committed Aug 16, 2018
1 parent 582660d commit cbee270
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ShopifyApp/Traits/AuthControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function authenticate()
}

// Save shop domain to session
config(['session.expire_on_close' => true]);
session(['shopify_domain' => ShopifyApp::sanitizeShopDomain($shopDomain)]);

if (!request('code')) {
Expand Down
4 changes: 4 additions & 0 deletions tests/Controllers/AuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ public function testAuthRedirectsBackToLoginWhenNoShop()

public function testAuthRedirectsUserToAuthScreenWhenNoCode()
{
$this->assertEquals(false, config('session.expire_on_close')); // Default for Laravel

$response = $this->post('/authenticate', ['shop' => 'example.myshopify.com']);
$response->assertSessionHas('shopify_domain');
$response->assertViewHas('shopDomain', 'example.myshopify.com');
$response->assertViewHas(
'authUrl',
'https://example.myshopify.com/admin/oauth/authorize?client_id=&scope=read_products,write_products&redirect_uri=http://localhost/authenticate'
);

$this->assertEquals(true, config('session.expire_on_close')); // Override in auth for a single request
}

public function testAuthAcceptsShopWithCodeAndUpdatesTokenForShop()
Expand Down

0 comments on commit cbee270

Please # to comment.