Still doesn't seem to be making it to my database.
So... obviously I'm missing something in the setup or somewhere... Thanks for all the help thus far @glena, by the way.
Like, where in the world do I actually put this... I find the instructions very vague.
\Auth0::onLogin(function($auth0User) {
echo 'FUCK ME';
die();
// See if the user exists
$user = User::where("auth0id", $auth0User->user_id)->first();
if ($user === null) {
// If not, create one
$user = new User();
$user->email = $auth0User->email;
$user->auth0id = $auth0User->user_id;
$user->nickname = $auth0User->nickname;
$user->name = $auth0User->name;
$user->save();
}
return $user;
});
Here is what I have thus far...
auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
Routes.php
Route::get('/auth0/callback', '\Auth0\Login\Auth0Controller@callback');
User.php (Model)
class User extends Authenticatable implements \Illuminate\Contracts\Auth\Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'auth0id', 'firstname', 'lastname', 'picture', 'nickname'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
AppServiceProvider.php
public function register()
{
/*
$this->app->bind(
'\Auth0\Login\Contract\Auth0UserRepository',
'\Auth0\Login\Repository\Auth0UserRepository'
);
*/
$this->app->bind(
'\Auth0\Login\Contract\Auth0UserRepository',
'\App\Repository\NewAuth0UserRepository');
}
NewAuth0UserRepository
namespace App\Repository;
use App\User;
use Auth0\Login\Repository\Auth0UserRepository;
class NewAuth0UserRepository extends Auth0UserRepository {
public function getUserByUserInfo($userInfo) {
return new User($userInfo['profile'], $userInfo['accessToken']);
}
}