Reputation: 719
I am using two registration on my Laravel Application, the default Laravel registration and Laravel Socialite. Both are working fine. When the user registers with default Laravel registration, it sends verification email, but it also sends a verification email with Laravel Socialite, I want to disable sending verification email using socialite but I don't know how to go about this.
Here is the code in my Login Controller
that handles Socialite
public function redirectToGoogle()
{
return Socialite::driver('google')->redirect();
}
public function handleGoogleCallback()
{
try {
$user = Socialite::driver('google')->user();
$finduser = User::where('google_id', $user->id)->first();
if($finduser){
Auth::login($finduser);
return redirect('/home');
}else{
$newUser = User::create([
'name' => $user->name,
'email' => $user->email,
'google_id'=> $user->id
]);
Auth::login($newUser);
return redirect()->back();
}
} catch (Exception $e) {
return redirect('auth/google');
}
}
Upvotes: 1
Views: 1078
Reputation: 46
Use this
$user=User::create([
'name'=>$googleUser->name,
'email'=>$googleUser->email,
'google_id'=>$googleUser->id,
'password'=>md5(rand(1,10000)),
]);
$user->markEmailAsVerified();
Upvotes: 3
Reputation: 88
Try using the now()
helper function, for example:
$newUser = User::create([
'name' => $user->name,
'email' => $user->email,
'google_id'=> $user->id,
'email_verified_at' => now(),
]);
Upvotes: 0