Laravel Email Verification Scaffolding
atnic/laravel-email-verification is a Laravel package for laravel email verification scaffolding.
It currently has 3 GitHub stars and 186 downloads on Packagist (latest version v0.1.4).
Install it with composer require atnic/laravel-email-verification.
Discover more Laravel packages by atnic
or browse all Laravel packages to compare alternatives.
Last updated
Laravel Email Verification is a package for generate scaffolding code for email verification within just few step.
But before that make sure you already config you .env especially for MAIL_* keys. I prefer you to set up using mailtrap.io, its super easy!
Okay, then this is the step to install Laravel Email Verification:
composer require atnic/laravel-email-verification
php artisan make:auth before, then runphp artisan make:email-verification
email_verified column to users tablephp artisan migrate
Atnic\EmailVerification\Traits\EmailVerifiable trait to User model.<?php
...
use Atnic\EmailVerification\Traits\EmailVerifiable;
class User extends Authenticatable
{
use EmailVerifiable;
...
app/Http/Kernel.php, modify $routeMiddleware property, change auth middleware<?php
...
class Kernel extends HttpKernel
{
...
protected $routeMiddleware = [
// 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth' => \Atnic\EmailVerification\Http\Middleware\Authenticate::class,
...
registered() method on RegisterController<?php
...
use Atnic\EmailVerification\Notifications\EmailVerification;
class RegisterController extends Controller
{
...
/**
* The user has been registered.
*
* @param \Illuminate\Http\Request $request
* @param mixed $user
* @return mixed
*/
protected function registered($request, $user)
{
$user->notify(new EmailVerification($user->generateEmailVerificationUrl()));
if ($user->isEmailVerificationTimeoutExpired()) {
auth()->logout();
return response()->redirectToRoute('verify_email.resend', [ 'email' => $user->email ])->with('status', __('email-verification::verify_email.link_sent'));
}
}
...
In User model you can add $emailVerificationTimeout using integer value that define how much time in minutes user can logged in even when their email is unverified yet. You can notify them that their email is not verified and can click this link to resend email verfication. route('verify_email.resend', [ 'email' => 'some_email' ]). The default is 0, so user can't be login if email is not verified.
If you discover a security vulnerability within Laravel Email Verification, please send an e-mail to Farid Inawan via [email protected]. All security vulnerabilities will be promptly addressed.
Laravel Email Verification is open-sourced package licensed under the MIT license.