The following method works just fine:
Copy all the routes from /vendor/laravel/framework/src/Illuminate/Routing/Router.php and paste them into web.php and comment out or delete Auth::routes() web.php Auth::routes() .
Then configure the conditional to enable and disable registration from .env. Duplicate the 503.blade.php file in views/errors and create 403 forbidden or whatever.
Add ALLOW_USER_REGISTRATION= to .env and control the user’s registration by setting it to true or false.
You now have full control over the routes, and the Vendor files remain untouched.
web.php
//Auth::routes(); // Authentication Routes... Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); Route::post('login', 'Auth\LoginController@login'); Route::post('logout', 'Auth\LoginController@logout')->name('logout'); // Registration Routes... if (env('ALLOW_USER_REGISTRATION', true)) { Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register'); Route::post('register', 'Auth\RegisterController@register'); } else { Route::match(['get','post'], 'register', function () { return view('errors.403'); })->name('register'); } // Password Reset Routes... Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request'); Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset'); Route::post('password/reset', 'Auth\ResetPasswordController@reset');
This is a combination of some of the previous answers, in particular Rafal G. and Daniel Sentore.
Jeffrey Mar 23 '17 at 17:58 2017-03-23 17:58
source share