From 5e9f7f3359b3676c770ea0bfeb7fdf4e1dbf011d Mon Sep 17 00:00:00 2001 From: Matt Young Date: Sun, 26 May 2024 22:22:16 -0500 Subject: [PATCH] Email verification working. --- app/Models/User.php | 5 ++- app/Providers/FortifyServiceProvider.php | 4 ++ config/fortify.php | 4 +- resources/views/auth/verify-email.blade.php | 43 +++++++++++++++++++++ routes/web.php | 4 ++ 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 resources/views/auth/verify-email.blade.php diff --git a/app/Models/User.php b/app/Models/User.php index def621f..5eedd37 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,12 +2,13 @@ namespace App\Models; -// use Illuminate\Contracts\Auth\MustVerifyEmail; + +use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; -class User extends Authenticatable +class User extends Authenticatable implements MustVerifyEmail { use HasFactory, Notifiable; diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.php index 201c43a..178b342 100644 --- a/app/Providers/FortifyServiceProvider.php +++ b/app/Providers/FortifyServiceProvider.php @@ -58,5 +58,9 @@ class FortifyServiceProvider extends ServiceProvider Fortify::resetPasswordView(function (Request $request) { return view('auth.reset-password', ['request' => $request]); }); + + Fortify::verifyEmailView(function () { + return view('auth.verify-email'); + }); } } diff --git a/config/fortify.php b/config/fortify.php index 91e9624..d2f3487 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -73,7 +73,7 @@ return [ | */ - 'home' => '/', + 'home' => '/dashboard', /* |-------------------------------------------------------------------------- @@ -146,7 +146,7 @@ return [ 'features' => [ Features::registration(), Features::resetPasswords(), - // Features::emailVerification(), + Features::emailVerification(), Features::updateProfileInformation(), Features::updatePasswords(), // Features::twoFactorAuthentication([ diff --git a/resources/views/auth/verify-email.blade.php b/resources/views/auth/verify-email.blade.php new file mode 100644 index 0000000..59fb0ad --- /dev/null +++ b/resources/views/auth/verify-email.blade.php @@ -0,0 +1,43 @@ + + Verify Email + @if ($errors->any()) +
+
Something went wrong!
+ +
    + @foreach($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + +
+
+ Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? + If you didn't receive the email, we will gladly send you another. + + @if(session('status') == 'verification-link-sent') +
+ A new verification link has been sent to the email address you provided during registration. +
+ @endif + +
+
+ @csrf + +
+ Resend Verification Email +
+
+ +
+ @csrf + + Logout +
+
+
+
+
diff --git a/routes/web.php b/routes/web.php index 86a06c5..5e926c5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,3 +5,7 @@ use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('welcome'); }); + +Route::get('/dashboard', function () { + return view('welcome'); +})->middleware('auth', 'verified');