Route [user.verification.notice] not defined / Override EnsureEmailIsVerified?

时光总嘲笑我的痴心妄想 提交于 2019-12-25 01:07:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!