https://stackoverflow.com/questions/42695917/laravel-5-4-disable-register-route/42700000
https://laracasts.com/discuss/channels/general-discussion/disable-registration-in-built-in-registration-laravel-53?page=1
These above link are references
I did this by changing the constructor in Auth\RegisterController.php From:
public function __construct()
{
$this->middleware('guest');
}
to:
public function __construct()
{
$this->middleware('auth');
}
This way you can create new users if you want, but you have to be logged in first.
You could try this.
Route::match(['get', 'post'], 'register', function(){
return redirect('/');
});
Add those routes just below the
Auth::routes()
to override the default registration routes. Any request to the /register
route will redirect to the baseUrl.
This is deceptively easy! You just need to override two methods in your
app/Http/Controllers/Auth/RegisterController.php
Class. See below which will prevent the form from being displayed and most importantly block direct POST requests to your application for registrations../**
* Show the application registration form.
*
* @return \Illuminate\Http\Response
*/
public function showRegistrationForm()
{
return redirect('login');
}
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
abort(404);
}
Comments
Post a Comment