Skip to content

Commit

Permalink
update to auth0 sdk v5
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Feb 22, 2017
1 parent 924fe4b commit c563a88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"require": {
"php": ">=5.3.0",
"illuminate/support": "5.*",
"auth0/auth0-php": "^4.0.0",
"auth0/auth0-php": "^5.0.0",
"illuminate/contracts": "5.*"
},
"autoload": {
Expand Down
20 changes: 16 additions & 4 deletions src/Auth0/Login/Auth0Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Config;
use Auth0\SDK\API\Authentication;
use Auth0\SDK\Auth0;
use Auth0\SDK\JWTVerifier;
use Illuminate\Contracts\Container\BindingResolutionException;

Expand All @@ -12,7 +13,9 @@
*/
class Auth0Service
{
private $auth0Config;
private $auth0;
private $authApi;
private $apiuser;
private $_onLoginCb = null;
private $rememberUser = false;
Expand All @@ -25,13 +28,13 @@ class Auth0Service
private function getSDK()
{
if (is_null($this->auth0)) {
$auth0Config = config('laravel-auth0');
$this->auth0Config = config('laravel-auth0');

$auth0Config['store'] = new LaravelSessionStore();
$this->auth0Config['store'] = new LaravelSessionStore();

$auth0 = new Authentication($auth0Config['domain'], $auth0Config['client_id']);
$this->authApi = new Authentication($this->auth0Config['domain'], $this->auth0Config['client_id']);

$this->auth0 = $auth0->get_oauth_client($auth0Config['client_secret'], $auth0Config['redirect_uri'], $auth0Config);
$this->auth0 = new Auth0($this->auth0Config);
}

return $this->auth0;
Expand All @@ -45,6 +48,15 @@ public function logout()
$this->getSDK()->logout();
}

/**
* Redirects the user to the hosted login page
*/
public function login($connection = null, $state = null, $aditional_params = [], $response_type = 'code')
{
$url = $this->authApi->get_authorize_link($response_type, $this->auth0Config['redirect_uri'], $connection, $state, $aditional_params);
return Redirect::to($url);
}

/**
* If the user is logged in, returns the user information.
*
Expand Down

0 comments on commit c563a88

Please sign in to comment.