I am using Laravel 4 and I want to use a filter which in turns checks with another filter. Following is a piece of code.
Route::filter('auth', function()
{
if(Auth::check()) {
// write code here
}
});
Route::filter('logged_in_as_user',array('before'=>'auth', function()
{
// check if user is a normal user
}));
Route::filter('logged_in_as_admin', array('before'=>'auth', function()
{
// check if user is a admin user
}));
Route::get('user/dashboard',array('before'=>'logged_in_as_user', function() {
//make view
}));
Route::get('user/dashboard',array('before'=>'logged_in_as_admin', function() {
//make view
}));
Route::post('/login', function()
{
Auth::attempt( array('email' => Input::get('email'), 'password' => Input::get('password')) );
if(Auth::check()) {
return Redirect::to('user/dashboard');
} else {
return Redirect::to('user/login')->with('flash_error', 'User Name or password not match');
}
});
Its more like I wan to have Role Based Authentication.
I get an error as
call_user_func_array() expects parameter 1 to be a valid callback, second array member is not a valid method