Untitled
Anonymous
php
09/01/2023 8:48 AM
956 B
24
Indexable
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Laravel\Socialite\Facades\Socialite;
class GoogleController extends Controller
{
public function redirectToGoogle()
{
return Socialite::driver('google')->redirect();
}
public function handleGoogleCallback()
{
$user = Socialite::driver('google')->user();
// You can now access the user's information using $user
// For example, $user->name, $user->email, $user->token, etc.
// Add your logic to authenticate or register the user here
return redirect()->route('home'); // Redirect to the desired page after authentication
}
}
Editor is loading...