Damir Miladinov has a good tutorial about creating email verification with activation code in Laravel 5.2

You can do this in two ways:

  1. not allow to login at all

  2. allow with reduced access

I will cover the first case.

enter image description here

Activation Email Received

In this example I will add mail confirmation on top of the Laravel's default auth scaffolding. It can be applied even if you already have working application.

If starting from scratch create a new laravel project and do the basic auth scaffold.

php artisan make:auth

Create a table which will hold all activation codes.

php artisan make:migration create_user_activations_table --create=user_activations

With these columns

Schema::create('user_activations', function (Blueprint $table) {
    $table->integer('user_id')->unsigned();
    $table->string('token')->index();
    $table->timestamp('created_at');
});

Add one more column to the users table (create new migration or add it to the existing one)

$table->boolean('activated')->default(false);

And start migrations

php artisan migrate

Next, we need ActivationRepository which will handle activation codes in database. Method getToken is taken from Illuminate/Auth/Passwords/DatabaseTokenRepository class. Other methods will be used in ActivationService.

<?php
namespace App;

use Carbon\Carbon;
use Illuminate\Database\Connection;

class ActivationRepository
{

    protecte