I want to change the default Laravel routes from /auth/login to just /login and vis-à-vis with register.
These are my routes:
Route::get('login', ['as' => 'getLogin', 'uses' => 'Auth\AuthController@getLogin']);
Route::post('login', ['as' => 'postLogin', 'uses' => 'Auth\AuthController@postLogin']);
Route::get('logout', ['as' => 'getLogout', 'uses' => 'Auth\AuthController@getLogout']);
Route::get('register', ['as' => 'getRegister', 'uses' => 'Auth\AuthController@getRegister']);
Route::post('register', ['as' => 'postRegister', 'uses' => 'Auth\AuthController@postRegister']);
Now the problem arises, that when a user tries to access an area that is guarded, the Authentication class kicks in, redirecting the unauthenticated user back to /auth/login instead of just /login.
I though I could solve the problem by setting the $loginPath in my AuthController like this:
protected $loginPath = '/login';
But it seems like the $loginPath is just used for unsuccessful login attempts, instead of unsuccessful authentication attempts, like documented in the AuthenticateUsers Class.
Well I managed to change the redirectURL in the Authenticate Class from this:
return redirect()->guest('auth/login');
to this:
return redirect()->guest('login');
Which solved the issue, yet I would like to set a property for this in my AuthController like this:
protected $redirectIfMiddlewareBlocks = '/login';
For this I check in the Authenticate Class if a property exists, which I set in the AuthController before:
return redirect()->guest(property_exists($this, 'redirectIfMiddlewareBlocks') ? $this->redirectIfMiddlewareBlocks : '/shouldnotbeused');
Yet I get the /shouldnotbeused url, instead of the one set by the redirectIfMiddlewareBlocks property in my AuthController.
How do I set up the path for the login route in my AuthController correctly?
redirect()->guest('login')
– andrewtweber