Exclude route from Laravel authentication
Unfortunately you can't exclude register with the current implementation of Route::auth()
.
You would have to specify all the routes manually so
// Authentication Routes...
$this->get('login', 'Auth\AuthController@showLoginForm');
$this->post('login', 'Auth\AuthController@login');
$this->get('logout', 'Auth\AuthController@logout');
// Password Reset Routes...
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
$this->post('password/reset', 'Auth\PasswordController@reset');
I think this is a fairly common thing to want to do it would be nice if there was a parameter to the auth
method to say without register maybe you could submit a pull-request to the project.
In the new releases you can do it like so (in your web.php file):
Auth::routes(['register'=>false]);
I just YOLO and change this in the RegisterController.php
public function __construct()
{
$this->middleware('guest');
}
to this
public function __construct()
{
$this->middleware('auth');
}
This makes the register page require you to be loged in to reach it.
It's a hack. But it is a good hack.
EDIT: and just add this to your seeder to make life easier:
$u1= new App\User;
$u1->name = 'Your name';
$u1->email = '[email protected]';
$u1->password = bcrypt('yourPassword');
$u1->save();