Laravel comes with a built-in authentication which is very great and excellent, but sometimes you don't need the entire suite in your project. For example, a certain project doesn't need users to register. So let's remove the registration link from the template. But that's not enough, because the respective routes, controllers and views still exist. Let's see how registration can be disabled in Laravel 5.5.


  • Go to your projects root directory and run the following command:

    php artisan make:auth

    Above command will create the required authentication routes, controllers and views.

  • Go to routes\web.php and you would see the following line added in it:

    Auth::routes()
  • So let's see what exactly happens with Auth::routes(). Behind the scenes, this calls vendor/laravel/framework/src/Illuminate/Routing/Router.php file having the method auth().

    // 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');
  • Above are all the routes that are applied out-of-the-box with laravel's built-in authentication. As a part of our exercise, we don't need registration route. So this can be achieved by:

    • Removing Auth::routes() from routes\web.php
    • And adding only those routes that are needed from above. (Copy all, and comment Registration routes)
  • Here is how routes\web.php will look after removing registration routes:

    //Auth::routes();
    
    // Authentication Routes...
    Route::get('admin/login', 'Auth\LoginController@showLoginForm')->name('login');
    Route::post('admin/login', 'Auth\LoginController@login');
    Route::post('admin/logout', 'Auth\LoginController@logout')->name('logout');
    
    // 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');