问题
I've been trying to implement multiple authentication login and registration is working fine in both group but verification route is not working after user registration. Is there any way possible to do this ?
This is my route
Route::group([
'prefix' => 'users',
'namespace' => 'Users',
'as' => 'user.'
],function(){
Auth::routes(['verify' => true]);
Route::get('/','Main@index');
Route::get('/dashboard','Main@index')->name('dashboard');
});
Route::group([
'prefix' => 'admins',
'namespace' => 'Admins',
'as' => 'admin.'
],function(){
Auth::routes();
Route::get('/','Main@index');
Route::get('/dashboard','Main@index')->name('dashboard');
});
回答1:
Okay, I searched a lot but the only way is to handle by manually so I updated my route and it worked here is the code,
Route::group([
'prefix' => 'admins',
'namespace' => 'Admins',
'as' => 'admin.'
],function(){
Auth::routes();
Route::get('/','Main@index');
Route::get('/dashboard','Main@index')->name('dashboard');
});
Route::get('email/verify', 'Users\Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'Users\Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'Users\Auth\VerificationController@resend')->name('verification.resend');
Route::group([
'prefix' => 'users',
'namespace' => 'Users',
'as' => 'user.'
],function(){
Auth::routes();
Route::get('/','Main@index');
Route::get('/dashboard','Main@index')->name('dashboard');
});
Also I wonder if it would be much easier and simpler if Auth::routes(['verify' => true]);
handles all by itself then only thing we've to manage is show method in VerificationController
, I hope they update this issue in upcoming Laravel versions, but it is also possible that I'm not aware of another way to do it, any help or suggestion appreciated.
回答2:
So this was alternately addressed here
Laracasts::Setting Email Verification Middleware route
Turns out passing the redirectToRoute can be done via the middleware.
$router->middleware(['auth:apiuser', 'verified:api.verification.notice'])
A real world example
Route::get('admin', 'AdminController@showProfile')->middleware('verified:admin.verification.notice');
来源:https://stackoverflow.com/questions/54500029/route-user-verification-notice-not-defined-override-ensureemailisverified