Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.7 Email Verification Routes

Tags:

php

laravel

On Laravel 5.7 Email verification feature added. But on my project i do not use the default route names and added a prefix for my own purpose. Now when i added following code to add the verify routes, it shows an error.

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

Error message shows that the verification.verify route does not exists. Where can i update this route name in my project? Or is it the only way to use this feature is to follow the default Auth Route names?

Project Source Code Is available at https://github.com/nasirkhan/laravel-starter/tree/l57

like image 698
nasirkhan Avatar asked Nov 30 '22 14:11

nasirkhan


2 Answers

Instead of using Auth::routes(['verify' => true]); just use Auth::routes(); and manually add these routes:

Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');

Then customise as you want :)

like image 198
tompec Avatar answered Dec 03 '22 04:12

tompec


Anyone who gets here and is looking for tompec's version for the latest Laravel, use the below. Notice the addition of /{hash}.

$this->get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
$this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');
$this->post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
like image 21
eskimo Avatar answered Dec 03 '22 05:12

eskimo