I need to disable my register route in Laravel 8. Tried
Auth::routes([
'register' => false,
'login' => false,
]);
but the application threw up an error.
RuntimeException
In order to use the Auth::routes() method, please install the laravel/ui package.
If anyone points out what needs to change, will be grateful.
Thanks
laravel provide by us default Auth::routes() in my web. php file for login, register, forgot passwords routes but you can easily do it using “Auth::routes(['register' => false]);” to disable any routes such as register.
in app/Http/Controller/Auth/RegisterController.php Show activity on this post. As of Laravel 5.7 you can pass an array of options to Auth::routes() . You can then disable the register routes with: Auth::routes(['register' => false]);
You can easily remove laravel standard authentication routes by setting false in your auth reference. E.g. Auth::routes(['register' => false]); . This also works for login , verify etc.
In addition, be sure to disable related routes, in routes/web.php
:
Route::get('/register', function() {
return redirect('/login');
});
Route::post('/register', function() {
return redirect('/login');
});
I changed according feature tests in tests/Feature/RegistrationTest.php
to try to keep work clean so I needed those redirections.
At the end of my routes/web.php
was the following line:
require __DIR__.'/auth.php';
In routes/auth.php
are listed all additional routes for user login/register/logout. Just comment out or remove /register
route from there.
Laravel 8 uses fortify authentication. To disable registration from your laravel app, you need to disable it from fortify, which is located on /config/fortify.php
'features' => [
// Features::registration(), // disable here
Features::resetPasswords(),
Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication(),
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With