diff --git a/composer.json b/composer.json index 82cca3fc..f77868b3 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "require": { "php": ">=5.4.0", "illuminate/support": "5.* | ^6.0", - "auth0/auth0-php": "^5.1.0", + "auth0/auth0-php": "^5.6.0", "illuminate/contracts": "5.* | ^6.0" }, "autoload": { diff --git a/src/Auth0/Login/Auth0Service.php b/src/Auth0/Login/Auth0Service.php index cc2b2f96..bc8e1372 100644 --- a/src/Auth0/Login/Auth0Service.php +++ b/src/Auth0/Login/Auth0Service.php @@ -10,6 +10,7 @@ use Config; use Illuminate\Contracts\Config\Repository; use Illuminate\Contracts\Container\BindingResolutionException; +use Illuminate\Http\RedirectResponse; /** * Service that provides access to the Auth0 SDK. @@ -50,7 +51,6 @@ public function __construct( $sessionStateHandler = new SessionStateHandler($sessionStorage); } - $auth0Config['store'] = $sessionStorage; $auth0Config['state_handler'] = $sessionStateHandler; $this->auth0 = new Auth0($auth0Config); @@ -79,8 +79,17 @@ public function logout() */ public function login($connection = null, $state = null, $additional_params = ['scope' => 'openid profile email'], $response_type = 'code') { + if ($connection && empty( $additional_params['connection'] )) { + $additional_params['connection'] = $connection; + } + + if ($state && empty( $additional_params['state'] )) { + $additional_params['state'] = $state; + } + $additional_params['response_type'] = $response_type; - $this->auth0->login($state, $connection, $additional_params); + $auth_url = $this->auth0->getLoginUrl($additional_params); + return new RedirectResponse($auth_url); } /** diff --git a/src/Auth0/Login/LaravelSessionStore.php b/src/Auth0/Login/LaravelSessionStore.php index 41f72cde..7f379a4e 100644 --- a/src/Auth0/Login/LaravelSessionStore.php +++ b/src/Auth0/Login/LaravelSessionStore.php @@ -20,12 +20,8 @@ class LaravelSessionStore implements StoreInterface public function set($key, $value) { $key_name = $this->getSessionKeyName($key); - Session::put($key_name, $value); - // The Auth0 SDK might decide to redirect and exit the PHP execution - // before the Laravel middleware can write the changes. - // thus we have to persist our changes early - Session::save(); + Session::put($key_name, $value); } /**