Friday, February 14, 2020

How to disable Register Route in Laravel

How to disable Register Route in Laravel

In this small post I would like to show you how you can deactivate the registration path in Laravel. if you can disable the registration path in the Laravel application. If you have any questions about deleting the registry path in Laravel, you've come to the right place.

You can deactivate the registration path in the Laravel 5 and Laravel 6 application.

I will give you two ways to clear the registration path in Laravel. Laravel provides standard authentication paths and creates login, registration and password routes. You can easily do this with "Auth :: route (['register' => false]);" to do.

So let's look at both ways of deleting the registry path in the Laravel application.


Example 1:


Here we use standard authentication paths with the pass array as an argument and pass 'register' false to disable the registration path in the Laravel application.
So you can do this as follows:

routes/web.php

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

You can also disabled 'reset' and 'verify' as like bellow:

Auth::routes([

'register' => false, // Register Routes...

'reset' => false, // Reset Password Routes...

'verify' => false, // Email Verification Routes...

]);


Example 2:


Here we create all routes manually in our web.php file instead of providing auth: route (). Then you can remove it since you don't need anything. This allows you to view the default routes listed below and delete the ones you don't need.

So you can do this as follows:

routes/web.php

/* 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')->name('password.update');

  

/* Email Verification 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');


I hope This Could help you...

0 comments:

Post a Comment

Please don't enter any spam link in the comment box.