Filter for multiple auth
Hi,
Is it possible to define a filter for every auth you use? I tried the following but it's not giving the desired results. Any ideas? Thanks!
Route::filter('auth', function() { if (Auth::company()->guest()) return Redirect::guest('company'); if (Auth::admin()->guest()) return Redirect::guest('admin'); });
Why don you create a new filter in regards to group your layered app,
/* Filters */
Route::filter('auth.company', function(){
if (Auth::company()->guest()){
return Redirect::guest('company');
}
});
Route::filter('auth.admin', function(){
if (Auth::admin()->guest()){
return Redirect::guest('admin');
}
});
/* Routes */
//Company Routes
Route::group(array('before' => 'auth.company'), function(){
//Some cool code here
}
//Admin Routes
Route::group(array('before' => 'auth.admin'), function(){
//Some cool code here
}
Perfect! Thank you very much! Loving this plugin
Hi, I want to limit the page access by admin, parent and student at the time of routing. How can I achieve that. Consider an example, suppose I don't want admin to access index page without logged in.