go to part...
First, let's mount the Laravel's authentication system into our project. Run the following command in your terminal inside the project's root folder:
php artisan make:auth
This will create all the required routes, controllers, and views. Now let's get rid of the registration. Go to your routes/web.php
file and remove the following line:
Auth::routes();
Then open the vendor/laravel/framework/src/Illuminate/Routing/Router.php
file and find the method called auth()
. This is what Auth::routes()
was calling behind the scenes. Copy it's content and paste it somewhere at the top of your routes/web.php
file.
// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');
This gives us the kind of control over the authentication routes we didn't have before. As you've probably guessed, all you have to do to hide the registration from your users is to remove the two registration routes from there. If you want to bring registration back sometime in the future you'll be able to just add these routes back.
If you're sure you won't need the registration again, you might also want to delete the controller (app/Http/Controllers/Auth/RegisterController.php
) and the view (resources/view/auth/register.blade.php
). That's it!
All the materials at voerro are absolutely free and are worked on in the author's spare time. If you found any of the tutorials helpful, please consider supporting the project. Thank you!