Skip to content

Commit 5ebbcf1

Browse files
committed
Bind SessionState handler interface in contianer
Binding the interface allows for an easier replacement with a different implmentation lateron.
1 parent 63ec44e commit 5ebbcf1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Auth0/Login/Auth0Service.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Auth0\Login;
44

55
use Auth0\SDK\API\Helpers\State\SessionStateHandler;
6+
use Auth0\SDK\API\Helpers\State\StateHandler;
67
use Auth0\SDK\Auth0;
78
use Auth0\SDK\Helpers\Cache\CacheHandler;
89
use Auth0\SDK\JWTVerifier;
@@ -37,7 +38,7 @@ class Auth0Service
3738
public function __construct(
3839
array $auth0Config = null,
3940
StoreInterface $sessionStorage = null,
40-
SessionStateHandler $sessionStateHandler = null
41+
StateHandler $stateHandler = null
4142
)
4243
{
4344
// Backwards compatible fallbacks
@@ -47,12 +48,12 @@ public function __construct(
4748
if (!$sessionStorage instanceof StoreInterface) {
4849
$sessionStorage = new LaravelSessionStore();
4950
}
50-
if (!$sessionStateHandler instanceof SessionStateHandler) {
51-
$sessionStateHandler = new SessionStateHandler($sessionStorage);
51+
if (!$stateHandler instanceof SessionStateHandler) {
52+
$stateHandler = new SessionStateHandler($sessionStorage);
5253
}
5354

5455
$auth0Config['store'] = $sessionStorage;
55-
$auth0Config['state_handler'] = $sessionStateHandler;
56+
$auth0Config['state_handler'] = $stateHandler;
5657
$this->auth0 = new Auth0($auth0Config);
5758
}
5859

src/Auth0/Login/LoginServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Auth0\SDK\API\Helpers\ApiClient;
66
use Auth0\SDK\API\Helpers\InformationHeaders;
77
use Auth0\SDK\API\Helpers\State\SessionStateHandler;
8+
use Auth0\SDK\API\Helpers\State\StateHandler;
89
use Auth0\SDK\Store\StoreInterface;
910
use Illuminate\Support\ServiceProvider;
1011

@@ -49,7 +50,7 @@ public function register()
4950
return new LaravelSessionStore();
5051
});
5152

52-
$this->app->bind(SessionStateHandler::class, function ($app) {
53+
$this->app->bind(StateHandler::class, function ($app) {
5354
return new SessionStateHandler($app->make(LaravelSessionStore::class));
5455
});
5556

0 commit comments

Comments
 (0)