Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jarcas's avatar

The 'verified' middleware isn't working on my routes

When I use the 'verified' middleware on a route group, it doesn't work - but when I use it in kernel.php's $middleware variable it does.

My routes/api.php file:

<?php

use App\Http\Controllers\V1\AccountController;
use App\Http\Controllers\V1\AccountFeeController;
use App\Http\Controllers\V1\AccountTypeController;
use App\Http\Controllers\V1\AuthController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware(['auth:sanctum'])->get('/user', function (Request $request) {
    return $request->user();
});

Auth::routes(['verify' => true]);

Route::prefix('v1')->group(function () {
    Route::middleware(['auth:sanctum', 'verified'])->group(function () {
        Route::apiResources([
            'account' => AccountController::class,
        ]);
    });

    // Auth / user
    Route::post('/user/register', [AuthController::class, 'register']);
    Route::post('/user/login', [AuthController::class, 'login']);
});

I used the breeze starter kit to get started

0 likes
6 replies
Niush's avatar

Does your User model class implements MustVerifyEmail interface?

Niush's avatar

@jarcas Well, everything looks correct. May be the route was cached. Try php artisan route:clear just in case. Or, may be the user was already verified.

1 like

Please or to participate in this conversation.