Skip to content

Email Verification

JetShip offers a fully featured User Email Verification system, but by default, it’s turned off. You can enable and configure email verification with just a few simple steps. Follow this guide to activate email verification in your project.

🛠️ Steps to Enable Email Verification

1. Modify the User Model

Head over to your User model located in app/Models/User.php.

  • Implement the MustVerifyEmail interface in the User class. This interface ensures that users must verify their email addresses before accessing certain routes.

  • If the MustVerifyEmail interface is not auto-imported, add it manually like so:

    php
    use Illuminate\Contracts\Auth\MustVerifyEmail;
  • Your User class should look like this:

    php
    class User extends Authenticatable implements FilamentUser, HasAvatar, MustVerifyEmail
    {
        // Your user model code...
    }

2. Protect Routes with the verified Middleware

If you want to restrict certain routes to only verified users, you can apply the verified middleware. This ensures that only users who have verified their email can access those routes.

Here’s an example where we protect the checkout route so that only verified users can access it:

php
Route::post('/checkout', [App\Http\Controllers\ProductController::class, 'checkoutProduct'])
    ->name('products.checkout')
    ->middleware('verified');

🔒 Voila! Your route is now protected

Unverified users won’t be able to access this route until they verify their email address.

✨ That's it

You’ve now successfully set up email verification in JetShip! This simple process adds an extra layer of security, ensuring that only verified users can access certain pages of your application. 🎉