Skip to content

Commit aad8af6

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 aad8af6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Auth0/Login/Auth0Service.php

Lines changed: 6 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;
@@ -31,13 +32,14 @@ class Auth0Service
3132
*
3233
* @param array $auth0Config
3334
* @param StoreInterface $sessionStorage
35+
* @param StateHandler|null $stateHandler
3436
*
3537
* @throws \Auth0\SDK\Exception\CoreException
3638
*/
3739
public function __construct(
3840
array $auth0Config = null,
3941
StoreInterface $sessionStorage = null,
40-
SessionStateHandler $sessionStateHandler = null
42+
StateHandler $stateHandler = null
4143
)
4244
{
4345
// Backwards compatible fallbacks
@@ -47,12 +49,12 @@ public function __construct(
4749
if (!$sessionStorage instanceof StoreInterface) {
4850
$sessionStorage = new LaravelSessionStore();
4951
}
50-
if (!$sessionStateHandler instanceof SessionStateHandler) {
51-
$sessionStateHandler = new SessionStateHandler($sessionStorage);
52+
if (!$stateHandler instanceof StateHandler) {
53+
$stateHandler = new SessionStateHandler($sessionStorage);
5254
}
5355

5456
$auth0Config['store'] = $sessionStorage;
55-
$auth0Config['state_handler'] = $sessionStateHandler;
57+
$auth0Config['state_handler'] = $stateHandler;
5658
$this->auth0 = new Auth0($auth0Config);
5759
}
5860

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)