How to redirect to auth / login in Laravel 5.1 if the visitor is not authenticated? [closed]

2

I am using Laravel 5.1 native authentication but when accessing a protected route the system does not redirect me to the login screen, instead it shows me the message "You do not have permission to access this resource."

The routes then this way:

Route::group(['prefix'=>'admin','before' => 'auth','middleware'=>['needsRole:Admin'],'namespace'=>'Admin'], function()
{
    Route::resource('/', 'HomeController');
    Route::resource('users','UsersController');
    Route::resource('stores','StoresController');
    Route::resource('templates','TemplatesController');
});
    
asked by anonymous 17.09.2015 / 20:37

1 answer

0

I was commenting on an error:

['prefix'=>'admin','before' => 'auth','middleware'=>['needsRole:Admin'],'namespace'=>'Admin']

When it actually is:

['prefix'=>'admin','middleware'=>['auth','needsRole:Admin'],'namespace'=>'Admin']
    
17.09.2015 / 21:39