I'm new to laravel
I have code in my __construct controller as
if(Auth::check())
{
return View::make('view_page');
}
return Redirect::route('login')->withInput()->with('errmessage', 'Please Login to access restricted area.');
works fine but i want to. its really annoying to put these encodings in each controller, so I want to put this Verify Auth and redirect to the login page in one place, maybe in router.phpor filters.php.
I read several forum posts as well as in stackoverflowand added the code to filters.phpas shown below, but this does not work either.
Route::filter('auth', function() {
if (Auth::guest())
return Redirect::guest('login');
});
Please help me solve this problem.
source
share