Skip to content

Commit e23b707

Browse files
committed
Adding back config check for state and store
1 parent 8562ddc commit e23b707

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/Auth0/Login/Auth0Service.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Auth0\Login;
44

5+
use Auth0\SDK\API\Helpers\State\SessionStateHandler;
56
use Auth0\SDK\API\Helpers\State\StateHandler;
67
use Auth0\SDK\Auth0;
78
use Auth0\SDK\Helpers\Cache\CacheHandler;
@@ -28,16 +29,26 @@ class Auth0Service
2829
* Auth0Service constructor.
2930
*
3031
* @param array $auth0Config
31-
* @param StoreInterface $sessionStorage
32+
* @param StoreInterface|null $store
3233
* @param StateHandler|null $stateHandler
3334
*/
3435
public function __construct(
3536
array $auth0Config,
36-
StoreInterface $sessionStorage,
37-
StateHandler $stateHandler
37+
StoreInterface $store = null,
38+
StateHandler $stateHandler = null
3839
)
3940
{
40-
$auth0Config['store'] = $sessionStorage;
41+
$store = isset( $auth0Config['store'] ) ? $auth0Config['store'] : $store;
42+
if (false !== $store && !$store instanceof StoreInterface) {
43+
$store = new LaravelSessionStore();
44+
}
45+
46+
$stateHandler = isset( $auth0Config['state_handler'] ) ? $auth0Config['state_handler'] : $stateHandler;
47+
if (false !== $stateHandler && !$stateHandler instanceof StateHandler) {
48+
$stateHandler = new SessionStateHandler($store);
49+
}
50+
51+
$auth0Config['store'] = $store;
4152
$auth0Config['state_handler'] = $stateHandler;
4253
$this->auth0 = new Auth0($auth0Config);
4354
}

src/Auth0/Login/LoginServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
use Auth0\SDK\API\Helpers\InformationHeaders;
77
use Auth0\SDK\API\Helpers\State\StateHandler;
88
use Auth0\SDK\API\Helpers\State\SessionStateHandler;
9-
use Auth0\SDK\API\Helpers\State\StateHandler;
109
use Auth0\SDK\Store\StoreInterface;
1110
use Illuminate\Support\ServiceProvider;
1211

1312
class LoginServiceProvider extends ServiceProvider
1413
{
1514

16-
const SDK_VERSION = "5.3.1";
15+
const SDK_VERSION = "7.0.0";
1716

1817
/**
1918
* Bootstrap the application events.

tests/Auth0ServiceTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
use Auth0\Login\Auth0Service;
55
use Auth0\Login\Facade\Auth0 as Auth0Facade;
6+
use Auth0\Login\LaravelSessionStore;
67
use Auth0\Login\LoginServiceProvider as Auth0ServiceProvider;
78
use Auth0\SDK\API\Helpers\State\DummyStateHandler;
89
use Auth0\SDK\Store\EmptyStore;
10+
use Auth0\SDK\Store\SessionStore;
911
use Orchestra\Testbench\TestCase as OrchestraTestCase;
1012
use Session;
1113

@@ -27,7 +29,7 @@ public static function setUpBeforeClass()
2729
public function testThatServiceUsesSessionStoreByDefault()
2830
{
2931
Session::put('auth0__user', '__test_user__');
30-
$service = new Auth0Service(self::$defaultConfig);
32+
$service = new Auth0Service(self::$defaultConfig, new LaravelSessionStore(), new DummyStateHandler());
3133
$user = $service->getUser();
3234

3335
$this->assertArrayHasKey('profile', $user);

0 commit comments

Comments
 (0)