I am trying to log a user in via Facebook and then use that user data to fill out the name and email in a comment form.
I am using Laravel / Socialite
.
So in my LoginController
I have this:
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Socialite;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function redirectToProvider()
{
return Socialite::driver('facebook')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('facebook')->user();
return redirect()->route('blog');
// $user->token;
}
}
By using breakpoints in both methods I came to the conclusion that the handleProviderCallback
method is actually never triggered for some reason.
So to make it clear, redirectToProvider
is triggered and it works, it does log me in via Facebook, but the handleProviderCallback
method is never triggered so I can't get user data.