How to Disable New User Registration in Laravel
In this short article, I would like to share how to disable new user registration in Laravel. Let’s see the way:
For New Versions
This method will work for new versions of Laravel. This method works might be from 5.6/5.7.
Open routes > web.php and simply change:
Auth::routes();
to:
Auth::routes(['register' => false]);
Using this method, you’re able to disable/enable register, reset password and email verification routes. Here’s the example:
Auth::routes([
'register' => false, // Register Route
'reset' => false, // Reset Password Route
'verify' => false, // Email Verification Route
]);
For Older Versions
If the first method doesn’t work on your Laravel app, try this method. Open AuthController or RegisterController (find any of this from your app) and simply modify showRegistrationForm()
and register()
methods.
public function showRegistrationForm()
{
return redirect('login');
}
public function register()
{
// empty
}
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.