From 262aad2d7a68aafbd5062c8c80c7b566bcf9b17c Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 9 Sep 2018 08:48:32 -0500 Subject: [PATCH] Add the Laravel 5.7 email verification --- .../Auth/VerificationController.php | 40 +++++++++++++++++++ app/Providers/EventServiceProvider.php | 6 +++ app/Routes/web.php | 2 +- .../layouts/default/auth/verify.blade.php | 25 ++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Auth/VerificationController.php create mode 100644 resources/views/layouts/default/auth/verify.blade.php diff --git a/app/Http/Controllers/Auth/VerificationController.php b/app/Http/Controllers/Auth/VerificationController.php new file mode 100644 index 00000000..09c86d76 --- /dev/null +++ b/app/Http/Controllers/Auth/VerificationController.php @@ -0,0 +1,40 @@ +middleware('auth'); + $this->middleware('signed')->only('verify'); + $this->middleware('throttle:6,1')->only('verify', 'resend'); + } +} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index f9874799..a202f469 100755 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -8,6 +8,8 @@ use App\Listeners\AwardListener; use App\Listeners\ExpenseListener; use App\Listeners\FinanceEvents; use App\Listeners\NotificationEvents; +use Illuminate\Auth\Events\Registered; +use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider @@ -17,6 +19,10 @@ class EventServiceProvider extends ServiceProvider ExpenseListener::class, ], + Registered::class => [ + SendEmailVerificationNotification::class, + ], + UserStatsChanged::class => [ AwardListener::class, ], diff --git a/app/Routes/web.php b/app/Routes/web.php index 343c88c4..e55642f6 100755 --- a/app/Routes/web.php +++ b/app/Routes/web.php @@ -44,7 +44,7 @@ Route::group([ Route::resource('profile', 'ProfileController'); }); -Auth::routes(); +Auth::routes(['verify' => true]); Route::get('/logout', 'Auth\LoginController@logout')->name('logout'); require app_path('Routes/admin.php'); diff --git a/resources/views/layouts/default/auth/verify.blade.php b/resources/views/layouts/default/auth/verify.blade.php new file mode 100644 index 00000000..f578db79 --- /dev/null +++ b/resources/views/layouts/default/auth/verify.blade.php @@ -0,0 +1,25 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Verify Your Email Address') }}
+ +
+ @if (session('resent')) + + @endif + + {{ __('Before proceeding, please check your email for a verification link.') }} + {{ __('If you did not receive the email') }}, {{ __('click here to request another') }}. +
+
+
+
+
+@endsection