我整合Facebook登錄我的web應用程序,但我得到這個錯誤:Laravel 5.4 - 創建用戶
ErrorException in SessionGuard.php line 407: Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, string given, called in /Applications/XAMPP/xamppfiles/htdocs/shop/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 294 and defined
我看到的問題是,當我創建新用戶:
public function findOrCreateUser($user, $provider)
{
$authUser = User::where('provider_id', $user->id)->first();
// if user exist login
if ($authUser) {
return $authUser;
}
// if user don't exist - Create new user
$test = DB::table('users')->insert([
'name' => $user->name,
'email' => $user->email,
'provider' => $provider,
'provider_id' => $user->id
]);
return 'Hello'; // just try if it work!
}
用戶創建正確,但我得到上述錯誤。我看不到我的消息「你好」。如果我更換這樣的創建方法:
return User::create([
'name' => $user->name,
'email' => $user->email,
'provider' => $provider,
'provider_id' => $user->id
]);
它運行良好。但是我不想在創建用戶後停止;我想回到另一種觀點。
我得到相同的錯誤:( –