LoginController is in redirect loop back to login route.
LoginController:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/register';
/**
* Create a new controller instance.
*
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function username()
{
return 'username';
}
}
routes/web.php :
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
// Enums Route //
Route::get('/genderEnum', 'EnumController@gender');
Route::get('/modelTypeEnum', 'EnumController@modelType');
Route::get('/classCodeEnum', 'EnumController@classCode');
Route::get('/statusEnum', 'EnumController@status');
Route::get('/titleEnum', 'EnumController@title');
// test routes //
Route::get('/test', 'TestController@test');
RouteServiceProvider:
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
// Route::middleware('web')
// ->namespace($this->namespace)
// ->group(base_path('routes/web.php'));
Route::group([
'middleware' => ['auth', 'web', 'guest'],
'namespace' => $this->namespace
],function(){
require base_path('routes/web.php');
});
// Route::group(array(
// 'middleware' => ['web', 'auth'],
// 'namespace' => $this->namespace,
// ), function ($router) {
// require base_path('routes/web.php');
// });
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
I think the problem has to do with my RouteServiceProvider. I am trying to auth users and when I hit other auth routes I am redirected back to Login view and then it continues into 302 redirect loop to the login GET route.