Skip to content

Commit 28ac3be

Browse files
committed
remove all code changes
1 parent 0464879 commit 28ac3be

File tree

5 files changed

+5
-56
lines changed

5 files changed

+5
-56
lines changed

src/Oauth2CredentialManagers/AuthenticatedUserStore.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ class AuthenticatedUserStore extends ModelStore
1010
{
1111
public function __construct()
1212
{
13-
$auth = Auth::guard(Xero::getDefaultAuthGuard());
14-
15-
if (! $auth->check()) {
13+
if (! Auth::check()) {
1614
throw new XeroUserNotAuthenticated('User is not authenticated');
1715
}
1816

1917
parent::__construct();
2018

21-
$this->model = $auth->user();
19+
$this->model = Auth::user();
2220
}
2321
}

src/Oauth2CredentialManagers/BaseCredentialManager.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Webfox\Xero\Oauth2CredentialManagers;
44

55
use Illuminate\Session\Store;
6-
use League\OAuth2\Client\Token\AccessTokenInterface;
76
use Webfox\Xero\Exceptions\XeroTenantNotFound;
87
use Webfox\Xero\Oauth2Provider;
98
use XeroAPI\XeroPHP\JWTClaims;
@@ -19,11 +18,6 @@ public function __construct()
1918
$this->oauthProvider = app(Oauth2Provider::class);
2019
}
2120

22-
23-
abstract public function exists(): bool;
24-
25-
abstract protected function store(AccessTokenInterface $token, array $tenants = null): void;
26-
2721
abstract protected function data(string $key = null);
2822

2923
public function getAccessToken(): string

src/Oauth2CredentialManagers/ModelStore.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ class ModelStore extends BaseCredentialManager implements OauthCredentialManager
1414

1515
public function __construct()
1616
{
17-
if($model = Xero::getModelStorage()) {
18-
$this->model = $model;
19-
}
17+
$this->model = Xero::getModelStorage();
2018

2119
parent::__construct();
2220
}

src/Xero.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
class Xero
88
{
9-
public static ?Model $modelStorage = null;
9+
public static Model $modelStorage;
1010

1111
public static string $modelAttribute = 'xero_credentials';
1212

13-
public static string $defaultAuthGuard = 'web';
14-
1513
public static function useModelStorage(Model $model): void
1614
{
1715
static::$modelStorage = $model;
@@ -22,7 +20,7 @@ public static function useAttributeOnModelStore(string $attribute): void
2220
static::$modelAttribute = $attribute;
2321
}
2422

25-
public static function getModelStorage(): ?Model
23+
public static function getModelStorage(): Model
2624
{
2725
return static::$modelStorage;
2826
}
@@ -31,14 +29,4 @@ public static function getModelAttribute(): string
3129
{
3230
return static::$modelAttribute;
3331
}
34-
35-
public static function getDefaultAuthGuard(): string
36-
{
37-
return static::$defaultAuthGuard;
38-
}
39-
40-
public static function setDefaultAuthGuard(string $guard): void
41-
{
42-
static::$defaultAuthGuard = $guard;
43-
}
4432
}

tests/Unit/CredentialManagersTest.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
use Illuminate\Cache\Repository;
66
use Illuminate\Foundation\Auth\User as Authenticatable;
7-
use Illuminate\Support\Facades\Config;
87
use Illuminate\Support\Facades\Session;
98
use Illuminate\Support\Facades\Storage;
109
use Mockery\MockInterface;
1110
use PHPUnit\Framework\Attributes\DataProvider;
1211
use Tests\Webfox\Xero\TestCase;
1312
use Tests\Webfox\Xero\TestSupport\Mocks\MockAccessToken;
1413
use Webfox\Xero\Exceptions\XeroCredentialsNotFound;
15-
use Webfox\Xero\Exceptions\XeroUserNotAuthenticated;
1614
use Webfox\Xero\Oauth2CredentialManagers\ArrayStore;
1715
use Webfox\Xero\Oauth2CredentialManagers\AuthenticatedUserStore;
1816
use Webfox\Xero\Oauth2CredentialManagers\CacheStore;
@@ -180,29 +178,6 @@ public function test_you_can_get_user($sutClass, $setupFunction, $createExisting
180178
], $sut->getUser());
181179
}
182180

183-
public function test_that_if_guest_it_will_throw_exception_for_authenticated_user_store()
184-
{
185-
$this->assertThrows(fn() => new AuthenticatedUserStore(), XeroUserNotAuthenticated::class, 'User is not authenticated');
186-
}
187-
188-
public function test_that_you_can_change_the_default_guard_for_users()
189-
{
190-
Config::set('auth.guards', array_merge(config('auth.guards'), [
191-
'admin' => [
192-
'driver' => 'session',
193-
'provider' => 'users',
194-
]
195-
]));
196-
197-
auth()->guard('admin')->login(User::create(['xero_credentials' => ['token' => 'foo']]));
198-
199-
$this->assertThrows(fn() => new AuthenticatedUserStore(), XeroUserNotAuthenticated::class, 'User is not authenticated');
200-
201-
Xero::setDefaultAuthGuard('admin');
202-
203-
$this->assertTrue((new AuthenticatedUserStore())->exists());
204-
}
205-
206181
public static function credentialManagers(): array
207182
{
208183
return [
@@ -245,10 +220,6 @@ public static function credentialManagers(): array
245220

246221
class User extends Authenticatable
247222
{
248-
protected $casts = [
249-
'xero_credentials' => 'array',
250-
];
251-
252223
protected function casts()
253224
{
254225
return [

0 commit comments

Comments
 (0)