Skip to content

Commit

Permalink
Merge pull request #23 from auth0/3.x.x-dev
Browse files Browse the repository at this point in the history
updated to be compatible with laravel 5.2
  • Loading branch information
glena committed Jan 6, 2016
2 parents 3f83c92 + d8b6e20 commit 38420f2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,44 @@ Check our docs page to get a complete guide on how to install it in an existing

> If you find something wrong in our docs, PR are welcome in our docs repo: https://github.com/auth0/docs
###Laravel 5.2

####Routes
Your routes need to be in the `web` routes group, otherwise it will not be able to use the session storage:

```
Route::group(['middleware' => ['web']], function () {
Route::get('/auth0/callback', '\Auth0\Login\Auth0Controller@callback');
Route::get('/', function () {
if (Auth::check()) dd('LOGGED IN',Auth::user());
return view('welcome');
});
});
```

####Auth setup

In your `config/auth.php` file update the providers to use the `auth0` driver:

```
...
'providers' => [
'users' => [
'driver' => 'auth0',
],
],
...
```

##Laravel Compatibility

The last version (2.x) targets Laravel 5 compatibility.
The 2.x branch targets Laravel 5.0 and 5.1 compatibility.
The 3.x branch targets Laravel 5.2 compatibility.

If you are working with an older version (Laravel 4.x) you need to point to composer.json to the version 1.0.*

Expand Down
9 changes: 9 additions & 0 deletions src/Auth0/Login/Auth0User.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ public function getAuthIdentifier() {
return $this->userInfo["user_id"];
}

/**
* Get id field name.
*
* @return string
*/
public function getAuthIdentifierName() {
return 'id';
}

/**
* Get the password for the user.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Auth0/Login/LaravelSessionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function set($key, $value) {
Session::put($key_name, $value);
}

public function get($key, $default=false) {
public function get($key, $default=null) {
$key_name = $this->getSessionKeyName($key);

return Session::get($key_name, $default);
Expand Down
11 changes: 3 additions & 8 deletions src/Auth0/Login/LoginServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ class LoginServiceProvider extends ServiceProvider {
*/
public function boot()
{
\Auth::extend('auth0', function($app) {

// Let the container build the repository for us
$userRepository = \App::make('\Auth0\Login\Contract\Auth0UserRepository');

$provider = new Auth0UserProvider($userRepository);

return new \Illuminate\Auth\Guard($provider, $app['session.store']);

\Auth::provider('auth0', function($app, array $config) {
$userRepository = \App::make(\Auth0\Login\Contract\Auth0UserRepository::class);
return new Auth0UserProvider($userRepository);
});

$this->publishes([
Expand Down

0 comments on commit 38420f2

Please sign in to comment.