redirect(); } public function callback() { try { $googleUser = Socialite::driver('google')->user(); $user = User::updateOrCreate([ 'email' => $googleUser->email, ], [ 'name' => $googleUser->name, 'google_id' => $googleUser->id, 'password' => bcrypt(Str::random(16)) ]); Auth::login($user); return redirect()->route('dashboard'); } catch (\Exception $e) { return redirect('/login')->withErrors(['msg' => 'Terjadi kesalahan saat login dengan Google.']); } } }