diff --git a/app/commands/AppCommand.php b/app/commands/AppCommand.php index b694f2879d..fa2dd7a487 100755 --- a/app/commands/AppCommand.php +++ b/app/commands/AppCommand.php @@ -223,7 +223,8 @@ class AppCommand extends Command 'name' => 'Admin', 'permissions' => array( 'admin' => 1, - 'users' => 1 + 'users' => 1, + 'reports' => 1 ) )); @@ -242,7 +243,8 @@ class AppCommand extends Command 'name' => 'Reporting', 'permissions' => array( 'admin' => 0, - 'users' => 1 + 'users' => 1, + 'reports' => 1, ) )); @@ -260,7 +262,8 @@ class AppCommand extends Command 'name' => 'Users', 'permissions' => array( 'admin' => 0, - 'users' => 1 + 'users' => 1, + 'reports' => 0, ) )); diff --git a/app/config/permissions.php b/app/config/permissions.php index f69987588b..bff298dc12 100755 --- a/app/config/permissions.php +++ b/app/config/permissions.php @@ -16,4 +16,12 @@ return array( ), ), + 'Reporting' => array( + array( + 'permission' => 'reports', + 'label' => 'View Reports', + ), + ), + + ); diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index 812cfbceb5..adc444b7d3 100755 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -7,10 +7,13 @@ class AdminController extends AuthorizedController * * @return void */ + public function __construct() { + // These have been moved into the routes for more granular control // Apply the admin auth filter - $this->beforeFilter('admin-auth'); + //$this->beforeFilter('admin-auth', array('except' => $this->whitelist)); + } diff --git a/app/database/migrations/2014_11_04_231416_update_group_field_for_reporting.php b/app/database/migrations/2014_11_04_231416_update_group_field_for_reporting.php new file mode 100644 index 0000000000..4a0ffd8dde --- /dev/null +++ b/app/database/migrations/2014_11_04_231416_update_group_field_for_reporting.php @@ -0,0 +1,37 @@ +hasAccess('reports')) { + // Show the insufficient permissions page + return Redirect::route('profile')->with("error","You do not have permission to view this page."); + } +}); + + /* |-------------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index c42d195dcd..5828fd66eb 100755 --- a/app/routes.php +++ b/app/routes.php @@ -9,7 +9,7 @@ | */ -Route::group(array('prefix' => 'hardware'), function () { +Route::group(array('prefix' => 'hardware', 'before' => 'admin-auth'), function () { @@ -46,7 +46,7 @@ Route::group(array('prefix' => 'hardware'), function () { # Asset Model Management - Route::group(array('prefix' => 'models'), function () { + Route::group(array('prefix' => 'models', 'before' => 'admin-auth'), function () { Route::get('/', array('as' => 'models', 'uses' => 'Controllers\Admin\ModelsController@getIndex')); Route::get('create', array('as' => 'create/model', 'uses' => 'Controllers\Admin\ModelsController@getCreate')); Route::post('create', 'Controllers\Admin\ModelsController@postCreate'); @@ -71,7 +71,7 @@ Route::group(array('prefix' => 'hardware'), function () { | */ -Route::group(array('prefix' => 'admin'), function () { +Route::group(array('prefix' => 'admin', 'before' => 'admin-auth'), function () { # Licenses @@ -246,7 +246,7 @@ Route::group(array('prefix' => 'auth'), function () { | */ -Route::group(array('prefix' => 'account'), function () { +Route::group(array('prefix' => 'account', 'before' => 'auth'), function () { # Account Dashboard Route::get('/', array('as' => 'account', 'uses' => 'Controllers\Account\DashboardController@getIndex')); @@ -279,12 +279,16 @@ Route::group(array('prefix' => 'account'), function () { | */ +Route::get('reports', array('as' => 'reports', 'before' => 'reporting-auth', 'uses' => 'Controllers\Admin\AssetsController@getReports')); + +Route::get('reports/export', array('as' => 'reports/export', 'before' => 'reporting-auth', 'uses' => 'Controllers\Admin\AssetsController@exportReports')); + // Redirect requests to / to the hardware section until we get a fancy dashboard set up Route::get('/', function () { return Redirect::to('hardware'); }); -Route::get('/', array('as' => 'home', 'uses' => 'Controllers\Admin\AssetsController@getIndex')); -Route::get('reports', array('as' => 'reports', 'uses' => 'Controllers\Admin\AssetsController@getReports')); -Route::get('reports/export', array('as' => 'reports/export', 'uses' => 'Controllers\Admin\AssetsController@exportReports')); +Route::get('/', array('as' => 'home', 'before' => 'admin-auth', 'uses' => 'Controllers\Admin\AssetsController@getIndex')); + + diff --git a/app/views/backend/layouts/default.blade.php b/app/views/backend/layouts/default.blade.php index c46263d0b3..f4849bb13f 100644 --- a/app/views/backend/layouts/default.blade.php +++ b/app/views/backend/layouts/default.blade.php @@ -225,11 +225,10 @@ @if (Sentry::check()) - @if(Sentry::getUser()->hasAccess('admin')) - @endif + @endif diff --git a/app/views/backend/users/edit.blade.php b/app/views/backend/users/edit.blade.php index ec6fe62489..8526ad8c9a 100755 --- a/app/views/backend/users/edit.blade.php +++ b/app/views/backend/users/edit.blade.php @@ -109,7 +109,7 @@
-