Disable register in Laravel

Laravel 5.2+ give us a way to scaffold all of the routes, controllers and views we need for authentication with one command:

php artisan make:auth

This command gives us 3 controllers (HomeController, AuthController and PasswordController) with some methods and the routes showed below, with the command:

php artisan route:list


If we want to disable the register, we have to disable the “showRegistrationForm” and the “register” methods in the “AuthController”, placed in the “app\Http\Controllers\Auth” folder.

This controller uses the “AuthenticatesAndRegistersUsers” trait, which uses the “RegistersUsers” trait.

We only have to overwrite this two methods in this controller (AuthController)

public function showRegistrationForm()
    return redirect('login');

public function register()

In the first method “showRegistrationForm()” we redirect the request to the login page and in the second method “register()” we do nothing.

We can delete the view “resources/views/auth/register.blade.php” because we won’t use it and we have it in the Git (or in another version control system) if we will need it.

Deixa unha resposta

O teu enderezo electrónico non se publicará Os campos obrigatorios están marcados con *

Este sitio emprega Akismet para reducir o spam. Aprende como se procesan os datos dos teus comentarios.