Support the ongoing development of Laravel.io →
posted 8 years ago
Authentication
Last updated 2 years ago.
0

i agree, they have changed the middleware's behavior since the last version. It does not behave as it did earlier.

your protected routes needs to have middleware 'web'. the easiest way to debug this is to check your protected routes have 'web' middleware.

try adding both web and auth middleware to the route group

0

That's not working. I tried adding:

Route::group(['middleware' => 'web', 'middleware' => 'auth'], function()

When I try to go to protected route, it just reloads the page.

And

Route::group(['middleware' => 'auth', 'middleware' => 'web'], function()

Same thing.

And tried leaving it as it was with just auth and wrapping all of my routes in a middleware web route group.

Same behavior as it previously had.

0

Routes does not go like that, if you want to add multiple middlewares you need to pass an array like this:

Route::group(['middleware' => ['web', 'auth']], function()
{
// all routes here will require the user to be logged in
});
0

Unfortunately, that didn't work either.

Does it matter where in web.php Auth::routes(); is?

0

It does not, but I did not clearly understand your problem, what's the main problem here?

0

I go to my website. Log in. That shows links to routes that require a user to be logged in. When I click one of those links, it takes me back to the login form.

0

That's strange, may you please add the whole web.php routes file?

0

Sure.

Route::get('/', array(
 	'as' => 'home',
 	'uses' => 'HomeController@getHome'
));


Route::get('watch/{id}', array(
 	'as' => 'home_watch_video',
 	'uses' => 'HomeController@getHomeWatch'
));

Route::get('search-results', array(
 	'as' => 'search_results',
 	'uses' => 'HomeController@getSearchResults'
));




foreach(File::allFiles(__DIR__.'/Routes/General') as $partial)
{
	require_once $partial->getPathname();
}

Route::group(['middleware' => ['web', 'auth']], function()
{
	
	Route::get('log-in/to', array(
	 	'as' => 'log_in_to',
	 	'uses' => 'HomeController@getAuthenticationForward'
	));

	foreach(File::allFiles(__DIR__.'/Routes/Admin') as $partial)
	{
		require_once $partial->getPathname();
	}
	foreach(File::allFiles(__DIR__.'/Routes/Admin/Shows') as $partial)
	{
		require_once $partial->getPathname();
	}
	foreach(File::allFiles(__DIR__.'/Routes/Admin/Productions') as $partial)
	{
		require_once $partial->getPathname();
	}
	foreach(File::allFiles(__DIR__.'/Routes/Admin/Recordings') as $partial)
	{
		require_once $partial->getPathname();
	}
	foreach(File::allFiles(__DIR__.'/Routes/Admin/Biographies') as $partial)
	{
		require_once $partial->getPathname();
	}
	foreach(File::allFiles(__DIR__.'/Routes/Admin/Venues') as $partial)
	{
		require_once $partial->getPathname();
	}
});



Route::get('login/facebook', array(
 	'as' => 'facebook_login',
 	'uses' => 'Auth\LoginController@facebookRedirect'
));
Route::get('login/facebook/callback', array(
 	'as' => 'facebook_callback',
 	'uses' => 'Auth\LoginController@facebookCallback'
));

Auth::routes();

Route::get('/home', 'HomeController@index');
0

Not sure what's wrong, here's my last app using laravel 5.3

https://github.com/ConsoleTVs/Laralum/blob/master/routes/web.php

0

Thanks for trying, Console. I appreciate the help.

Does anyone else have a clue? I'm dead in the water using 5.3.

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jerauf jerauf Joined 16 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.