Reputation: 1776
I use laravel 5.6
I want to disable registration for new users, of course the login form must work
I see below question :
https://stackoverflow.com/questions/29183348/how-to-disable-registration-new-user-in-laravel-5
But I did not find the showRegistrationForm()
function on the following path:
Auth/RegisterController.php
Upvotes: 2
Views: 3491
Reputation: 53
$this->middleware('auth');
insted of :
$this->middleware('guest');
and you can use register again by copying
public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
$this->guard()->login($user);
return $this->registered($request, $user)
?: redirect($this->redirectPath());
}
form RegisterUser.php to Register controller which follow OOP overriding method
Upvotes: 1
Reputation: 149
You may use middleware auth in RegisterController :
$this->middleware('auth');
instead of :
$this->middleware('guest');
Upvotes: 2
Reputation: 49
In routes/web.php
you can do:
Route::any('/auth/register','HomeController@index');
Upvotes: 0
Reputation: 126
In routes/web.php do:
Auth::routes(['register' => false]);
It works for me.
Upvotes: 11
Reputation: 6666
Remove the use RegistersUsers;
trait from the Auth/RegisterController
; This trait (located in vendor/laravel/framework/src/Illuminate/Foundation/Auth/RegistersUsers.php
) handles the register form.
The routes are registered in vendor/laravel/framework/src/Illuminate/Routing/Router.php
in the auth()
method.
After removing the trait, the routes are probably still in effect due to the stuff mentioned above. So to keep a good working app, write your own showRegistrationForm()
and register()
methods in the Auth/RegisterController.php
where you redirect both methods to something like the login route or the homepage.
Upvotes: 0