javascript - How to send verification email with laravel's built in verification system with Gmail

785

With regular sign ups the user will receive a verification email. But gmail users they do not receive the email unless they click the resend button.

How do I make gmail users to receive the verification email without having to click the resend button when they register?

<?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
187

Answer

Solution:

But 2 flags in DB, verified and is_email_sent. When user logs in check for verified if he is not, send email if is_email_sent false, otherwise log in user

People are also looking for solutions to the problem: php - How to properly re-order POST array coming from HTML?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.