Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.4 Disable Register Route

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?

like image 412
Dev.W Avatar asked Mar 09 '17 12:03

Dev.W


People also ask

How to disable register Route in laravel?

As of Laravel 5.7 you can pass an array of options to Auth::routes() . You can then disable the register routes with: Auth::routes(['register' => false]);

How to disable register in laravel 8?

People can't login without an account, so just disable the register feature in config/fortify. php . The laravel/ui package is designed for Laravel 6 and 7 -- it can be installed with Laravel 8 too, but the "new thing" there is Jetstream for your authentication scaffolding.


2 Answers

The code:

Auth::routes(); 

its a shorcut for this collection of routes:

// Authentication Routes... Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); Route::post('login', 'Auth\LoginController@login'); Route::post('logout', 'Auth\LoginController@logout')->name('logout');  // Registration Routes... Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register'); Route::post('register', 'Auth\RegisterController@register');  // Password Reset Routes... Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request'); Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset'); Route::post('password/reset', 'Auth\ResetPasswordController@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', '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'); 

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

Auth::routes(['reset' => false, 'verify' => false]); 
like image 143
dparoli Avatar answered Sep 21 '22 17:09

dparoli


Since Laravel 5.7, a new $options parameter is introduced to the Auth::routes() method; through which you can pass an array to control the generation of the required routes for user-authentication (valid entries can be chosen from the 'register', 'reset', or 'verify' string literals).

Auth::routes(['register' => false]); 
like image 34
Irwing Reza Avatar answered Sep 24 '22 17:09

Irwing Reza