How to authenticate multiple user groups in Laravel 5?

2

I'm trying to create an environment in laravel 5 where there is the customer access area (Front of Shop) and the administration area of pages, products, etc. (CMS), but the problem is that I can not find a way to split the sessions, for example: when I authenticate an account as administrator through the CMS login area, that same session is valid for the whole site, and therefore the administrator can access the urls that only authenticated users could, such as the User Panel, for example, and vice versa.

// CMS ADMINISTAÇÃO
Route::group(array('prefix' => '/admin', 'middleware' => ['auth', 'roles'], 'roles' => 'administrator'), function()
{   
    // INDEX
    Route::any('/', array('as' => 'admin', 'uses' => 'Admin\AdminController@Index'));
});

// PAINEL DO USUÁRIO
Route::group(array('middleware' => ['auth', 'roles'], 'roles' => 'client', 'prefix' => '/panel',), function(){
    Route::get('/', array('as' => 'panel', 'uses' => 'PanelController@Index'));
});

For this I implement this system of roles, which through the routes identifies if the user has sufficient permission to access that area, the problem is that after login the session would work anywhere, and even if I use some filter would still not allow me to have an administrator account logged into the CMS and another user account logged into the normal site, unless I split the application into 2, which I would not want to do.

In summary, what I want is that both sessions can exist at the same time, without one being able to access what is restricted to another.

How can I resolve this?

    
asked by anonymous 26.03.2015 / 03:59

1 answer

1

One solution I see for this situation would be to create authentication middleware for users, and another for administrators.

    
25.08.2015 / 03:41