This is an old question but today with 6.9 I am having the exact same issue.
If I put the route in the global routes/web.php it works, however when I put it in the package's routes file, it fails to detect that I am logged in and redirects to /login, but then it sees I am logged in so it redirects to /home.
It does not matter if you use the middleware on the route or in the controller constructor.
How did you solve this?
Jan 5, 2017
2
Level 7
Package controller not called when using middleware('auth'), while signed in.
Hello,
I'm still a bit new at this, and thought the best way to get my feet wet would be to try and create a package. Everything's good so far, and a view is being served at the /moddler route, so long as I don't add ->middleware('auth') to either the route nor the controller constructor. And this is while I'm signed in. So if I go to /moddler while signed in, it just redirects to /home instead. I'm probably missing something basic here, but would appreciate it if someone could point me in the right direction.
This works:
Route::get('/moddler', 'Moddler\ModdlerController@index');
<?php
namespace Moddler;
use App\Http\Controllers\Controller;
class ModdlerController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('moddler::test');
}
}
But neither of these work:
Route::get('/moddler', 'Moddler\ModdlerController@index')->middleware('auth');
<?php
namespace Moddler;
use App\Http\Controllers\Controller;
class ModdlerController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('moddler::test');
}
}
Many thanks!
Please or to participate in this conversation.