I have this function for google login
function :
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,
'google_id' => $googleUser->id,
'password' => encrypt('test@123')
]);
Auth::login($createUser);
return redirect('/home');
}
} catch (Exception $exception) {
dd($exception);
}
}
but i have created a specific guard for user login :
'user' => [
'driver' => 'session',
'provider' => 'users',
],
how i will change the guard to user when i login in the application through socialite Any suggestion Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire