|
2 | 2 |
|
3 | 3 | namespace Auth0\Login; |
4 | 4 |
|
| 5 | +use Auth0\SDK\API\Helpers\State\StateHandler; |
5 | 6 | use Auth0\SDK\API\Helpers\State\SessionStateHandler; |
6 | 7 | use Auth0\SDK\Auth0; |
7 | 8 | use Auth0\SDK\Helpers\Cache\CacheHandler; |
@@ -36,23 +37,26 @@ class Auth0Service |
36 | 37 | */ |
37 | 38 | public function __construct( |
38 | 39 | array $auth0Config = null, |
39 | | - StoreInterface $sessionStorage = null, |
40 | | - SessionStateHandler $sessionStateHandler = null |
| 40 | + StoreInterface $store = null, |
| 41 | + StateHandler $stateHandler = null |
41 | 42 | ) |
42 | 43 | { |
43 | | - // Backwards compatible fallbacks |
44 | 44 | if (!$auth0Config instanceof Repository && !is_array($auth0Config)) { |
45 | 45 | $auth0Config = config('laravel-auth0'); |
46 | 46 | } |
47 | | - if (!$sessionStorage instanceof StoreInterface) { |
48 | | - $sessionStorage = new LaravelSessionStore(); |
| 47 | + |
| 48 | + $store = $auth0Config['store'] ?? $store; |
| 49 | + if (false !== $store && !$store instanceof StoreInterface) { |
| 50 | + $store = new LaravelSessionStore(); |
49 | 51 | } |
50 | | - if (!$sessionStateHandler instanceof SessionStateHandler) { |
51 | | - $sessionStateHandler = new SessionStateHandler($sessionStorage); |
| 52 | + |
| 53 | + $stateHandler = $auth0Config['state_handler'] ?? $stateHandler; |
| 54 | + if (false !== $stateHandler && !$stateHandler instanceof StateHandler) { |
| 55 | + $stateHandler = new SessionStateHandler($store); |
52 | 56 | } |
53 | 57 |
|
54 | | - $auth0Config['store'] = $sessionStorage; |
55 | | - $auth0Config['state_handler'] = $sessionStateHandler; |
| 58 | + $auth0Config['store'] = $store; |
| 59 | + $auth0Config['state_handler'] = $stateHandler; |
56 | 60 | $this->auth0 = new Auth0($auth0Config); |
57 | 61 | } |
58 | 62 |
|
|
0 commit comments