При отладке ошибки я обнаружил, что мой Auth::login($user) работает неправильно.
Вот код:
AuthController.php
Код: Выделить всё
use App\Http\Controllers\Controller;
use Laravel\Socialite\Two\InvalidStateException;
use Auth;
use Socialite;
use App\User;
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}
public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->user();
// dd($user);
$authUser = $this->findOrCreateUser($user, $provider);
// dd($authUser);
if(Auth::login($authUser, true)){ // here is the error
return redirect($this->redirectTo);
}
else{
return 'Login not done'; //this prints out to the screen
}
}
public function findOrCreateUser($user, $provider)
{
$authUser = User::where('id', $user->id)->first();
if ($authUser) {
return $authUser;
}
return User::create([
'name' => $user->name,
'email' => $user->email,
'avatar' => $user->avatar,
'password' => bcrypt('password'),
'provider' => $provider,
'id' => $user->id
]);
}
Вот что я получаю, пока dd($authUser)

Мобильная версия