通过常规注册,用户将收到验证电子邮件。但是gmail用户只有单击重新发送按钮才能收到电子邮件。
我如何使gmail用户注册时无需点击重新发送按钮即可接收验证电子邮件?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Socialite;
use Auth;
use Exception;
class GoogleAuth extends Controller
{
public function redirectToProvider()
{
return Socialite::driver('google')->redirect();
}
public function handleProviderCallback()
{
try {
$googleUser = Socialite::driver('google')->user();
$existUser = User::where('email', $googleUser->email)->first();
if ($existUser) {
Auth::loginUsingId($existUser->id);
} else {
$user = new User;
$user->name = $googleUser->name;
$user->email = $googleUser->email;
$user->google_id = $googleUser->id;
$user->password = md5(rand(1, 10000));
$user->save();
Auth::loginUsingId($user->id);
}
return redirect()->to('/home');
} catch (Exception $e) {
return 'error';
}
}
}[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/gt4tM.png
答案 0 :(得分:0)
但是DB中有2个标记,已验证并被is_email_sent发送。用户登录时检查是否通过验证,如果is_email_sent为false,则发送电子邮件,否则登录用户