Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to disable the register route on my application which is running in Laravel 5.4.

In my routes file, I have only the

Auth::routes();

Is there any way to disable the register routes?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
424 views
Welcome To Ask or Share your Answers For Others

1 Answer

The code:

Auth::routes();

its a shorcut for this collection of routes:

// Authentication Routes...
Route::get('login', 'AuthLoginController@showLoginForm')->name('login');
Route::post('login', 'AuthLoginController@login');
Route::post('logout', 'AuthLoginController@logout')->name('logout');

// Registration Routes...
Route::get('register', 'AuthRegisterController@showRegistrationForm')->name('register');
Route::post('register', 'AuthRegisterController@register');

// Password Reset Routes...
Route::get('password/reset', 'AuthForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'AuthForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'AuthResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'AuthResetPasswordController@reset');

So you can substitute the first with the list of routes and comment out any route you don't want in your application.

Edit for laravel version => 5.7

In newer versions you can add a parameter to the Auth::routes() function call to disable the register routes:

Auth::routes(['register' => false]);

The email verification routes were added:

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

BTW you can also disable Password Reset and Email Verification routes:

Auth::routes(['reset' => false, 'verify' => false]);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...