Laravel 5.7 email verification error, route [verification.verify] not defined
Asked Answered
S

5

16

I am trying to implement email verification in Laravel 5.7. I have implemented MustVerifyEmail on User model.

class User extends Authenticatable implements MustVerifyEmail 
{ 
}

But after registration I got this error Route [verification.verify] not defined.

What I am missing in this? Please guide?

Survive answered 4/10, 2018 at 19:5 Comment(0)
E
4

What really happens:

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {

(['auth:sanctum', 'verified']

when passing two arguments of laravel one of authentication and the other of verification of mail. It says: it is authenticated. 😎 and verified 🙄 ok response: Respond that the user in the table: User email_verified_at is not registered on the email activation date, that is, it has not told me that the email exists. ps passes an exception for that there is a page that you must active as a response to this ... that is, as a response to this ... Your email is not verified even if the page is created either in vue on blade or in limewire in the auth folder.

in App\Models\User search

 // use Illuminate\Contracts\Auth\MustVerifyEmail;

active:

use Illuminate\Contracts\Auth\MustVerifyEmail;

eh implements

class User extends Authenticatable implements MustVerifyEmail

now many things are missing .. We verify that kernel is active the following parameters :

in route App\Http\Kernel.php

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

change:

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

in the folder Config: config\fortify.php this:

    // Features::emailVerification(),

it

    Features::emailVerification(),

And the most important of this authentication hell .. the routes: You can do the different types of routes you choose ... but one according to your resources or project.

basic:

Route::middleware(['auth:sanctum'])->get('/dashboard', function () {
        return Inertia::render('Dashboard');
})->middleware('verified')->name('dashboard');

Route::middleware(['auth:sanctum','verified'])->get('/dashboard', function () {
        return Inertia::render('Dashboard');
})->name('dashboard');

a little adrenaline:

Route::group(["middleware" => ['auth:sanctum','verified']], function () {
    Route::get('/dashboard', function () {
        return Inertia::render('Dashboard');
        // return "hola william";
    })->name('dashboard');
    //aca puedes segir colocando las paginas o recursos que quieres cargar mientras en usuario este autenticado y verificado...
});

where does the error come from: Route [verification.verify] not defined

this route/file.. vendor\laravel\framework\src\illuminate\Auth\Middleware\EnsureEmailsVerified.php

function:

    public function handle($request, Closure $next, $redirectToRoute = null)
{
    if (! $request->user() ||
        ($request->user() instanceof MustVerifyEmail &&
        ! $request->user()->hasVerifiedEmail())) {
        return $request->expectsJson()
                ? abort(403, 'Your email address is not verified.')
                : Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));
    }

    return $next($request);
}

linea:

: Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));

Thank you and success in your projects with laravel. and sorry if I wrote something wrong.

Espy answered 2/6, 2021 at 2:38 Comment(0)
T
2

In routes/web.php file, add following piece of code:

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

Ref: https://laravel.com/docs/5.7/verification#verification-routing

Tattle answered 11/6, 2019 at 10:17 Comment(0)
L
2

Run:

php artisan optimize:clear

It will clear your cache.

Lanoralanose answered 6/11, 2020 at 15:42 Comment(0)
B
0

In routes/web.php ensure Auth::routes(['verify' => true]); Then run :

php artisan route:cache

to clear cached routed and update incoming changes

Blest answered 13/10, 2020 at 5:32 Comment(0)
C
0

You can remove 'verified' middleware, for example:

<?php

Route::middleware(['auth', 'verified'])
    ->group(function(){

     ...

});

?>

Try it, should solve the problem

Caviness answered 18/10, 2020 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.