I’m using Laravel. I want to disable registration for new users but I need the login to work.
How can I disable registration form/routes/controllers?
Advertisement
Answer
Laravel 5.7 introduced the following functionality:
Auth::routes(['register' => false]);
The currently possible options here are:
Auth::routes([ 'register' => false, // Registration Routes... 'reset' => false, // Password Reset Routes... 'verify' => false, // Email Verification Routes... ]);
For older Laravel versions just override showRegistrationForm() and register() methods in
AuthControllerfor Laravel 5.0 – 5.4Auth/RegisterController.phpfor Laravel 5.5
public function showRegistrationForm()
{
return redirect('login');
}
public function register()
{
}