Hey there fellow developers,
I am struggling a little bit with laravel routing. I just build the login code and logging in seems to work properly. However when I am redirected to "/" I end up getting a redirect loop.
When guest the default url = "/" and when authenticated the default url also = "/", so my guess something is not working the way I intend it there.
The relevant routes code is as follows:
Route::group(["before" => "guest"], function() {
Route::any("/", [
"as" => "home/splash",
"uses" => "HomeController@showSplash"
]);
});
Route::group(["before" => "auth"], function() {
Route::any("/", [
"as" => "home/dashboard",
"uses" => "HomeController@showDashboard"
]);
});
When I remove the before auth group it loads the splash page. When I change the name of before "auth" to "auth5" for instance, it loads the dashboard.. but auth5 is not programmed in, in any place in my code.. so either I am totally obvlivious to how these route groups are supposed to work or I am doing something stupidly wrong :p
Last but not least, my auth filter also redirects to "/"
Regards,
Pwnball
Update =>
/* GUESTS GROUP */
Route::group(["before" => "guest"], function() {
Route::any("/splash", [
"as" => "home/splash",
"uses" => "HomeController@showSplash"
]);
/* AUTHENTICATED USERS GROUP */
Route::group(['before' => 'auth'], function() {
Route::any("/dashboard", [
"as" => "home/dashboard",
"uses" => "HomeController@showDashboard"
]);
This works.. but now my website cannot be reached as "/" anymore. This is frustrating for obvious reasons..
When I add this route in the before => guest group:
Route::any("/", [
"as" => "home/home",
"uses" => "HomeController@showSplash"
]);
It goes right back into redirect loops. My filter looks as follows:
Route::filter('auth', function()
{
if (Auth::guest())
{
if (Request::ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('/splash');
}
}
});
Route::filter('guest', function()
{
if (Auth::check()) return Redirect::to('/');
});
I must really be missing something obvious :)