Skip to content

Commit 00b423d

Browse files
author
Tyler King
committed
Fix to peruser/offline token check
1 parent 98cfb48 commit 00b423d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/ShopifyApp/Traits/ShopModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function isFreemium(): bool
114114
*/
115115
public function hasOfflineAccess(): bool
116116
{
117-
return ! $this->getToken()->isNull();
117+
return ! $this->getToken()->isNull() && !empty($this->password);
118118
}
119119

120120
/**

tests/Traits/ShopModelTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ public function testModel(): void
3535
$this->assertInstanceOf(IApiHelper::class, $shop->apiHelper());
3636
}
3737

38+
public function testOfflineToken(): void
39+
{
40+
// No token
41+
$shop = factory($this->model)->create([
42+
'password' => '',
43+
]);
44+
$this->assertFalse($shop->hasOfflineAccess());
45+
46+
// With token
47+
$shop->password = 'abc123';
48+
$shop->save();
49+
$shop->refresh();
50+
$this->assertTrue($shop->hasOfflineAccess());
51+
}
52+
3853
public function testNamespacingAndFreemium()
3954
{
4055
$this->app['config']->set('shopify-app.billing_freemium_enabled', true);

0 commit comments

Comments
 (0)