I have this link on my modal popup
<li><a href="" target="_blank"><i class="fab fa-google-plus-g"></i></a></li>
and routes is
Route::get('google', 'SocialiteAuthController@googleRedirect')->name('auth/google');
Route::get('/auth/google-callback', 'SocialiteAuthController@loginWithGoogle');
Services.php
'google' => [
'client_id' => 'XXXXXXXXXXXXXXXX.apps.googleusercontent.com',
'client_secret' => 'XXXXXXXXXXXXX',
'redirect' => 'http://localhost:8000/login/google/callback',
],
Controller:
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use Socialite;
use Illuminate\Support\Facades\Auth;
use Exception;
class SocialiteAuthController extends Controller
{
public function googleRedirect()
{
return Socialite::driver('google')->redirect();
}
/**
* Facebook login authentication
*
* @return void
*/
public function loginWithGoogle()
{
try {
$googleUser = Socialite::driver('google')->user();
$user = User::where('google_id', $googleUser->id)->first();
if($user){
Auth::login($user);
return redirect('/home');
}
else{
$createUser = User::create([
'name' => $googleUser->name,
'email' => $googleUser->email,
'fb_id' => $googleUser->id,
'password' => encrypt('test@123')
]);
Auth::login($createUser);
return redirect('/home');
}
} catch (Exception $exception) {
dd($exception->getMessage());
}
}
}
Guard :
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'user' => [
'driver' => 'session',
'provider' => 'users',
],
but when i login i'm getting this page 404 not found
Any solution, Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire