What’s New in Laravel 5.7: Email Verification

0
207

 

https://laravel.com/docs/5.7/releases

Laravel 5.7

Laravel 5.7 continues the improvements made in Laravel 5.6 by introducing Laravel Nova, optional email verification to the authentication scaffolding, support for guest users in authorization gates and policies, console testing improvements, Symfony dump-serverintegration, localizable notifications, and a variety of other bug fixes and usability improvements.

Email Verification

Laravel 5.7 introduces optional email verification to the authentication scaffolding included with the framework. To accommodate this feature, an email_verified_at timestamp column has been added to the default users table migration that is included with the framework.

To prompt newly registered users to verify their email, the User model should be marked with the MustVerifyEmail interface:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
    // ...
}

Once the User model is marked with the MustVerifyEmail interface, newly registered users will receive an email containing a signed verification link. Once this link has been clicked, Laravel will automatically record the verification time in the database and redirect users to a location of your choosing.

verified middleware has been added to the default application’s HTTP kernel. This middleware may be attached to routes that should only allow verified users:

'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

 

First up, we have email verification support out of the box in Laravel 5.7. It’s as simple as adding implements MustVerifyEmail to your User class. Seriously.

Tutorial

1: https://laracasts.com/series/whats-new-in-laravel-5-7/episodes/1

LEAVE A REPLY

Please enter your comment!
Please enter your name here