multiauth icon indicating copy to clipboard operation
multiauth copied to clipboard

Filter for multiple auth

Open notflip opened this issue 12 years ago • 3 comments

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'); });

notflip avatar Aug 25 '14 12:08 notflip

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
}

mikkezavala avatar Aug 27 '14 02:08 mikkezavala

Perfect! Thank you very much! Loving this plugin

notflip avatar Aug 27 '14 06:08 notflip

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.

muna9595 avatar Oct 01 '14 06:10 muna9595