From 33befbe3d03dd42f705123024345da9d652d064a Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Sun, 17 Jan 2016 05:43:28 -0800 Subject: [PATCH] #1: Darklaunched search to site staff. --- app/Http/routes.php | 2 +- app/Providers/AuthServiceProvider.php | 4 ++++ resources/views/shared/_app_layout.blade.php | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index 57f3edb5..401fd813 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -82,7 +82,7 @@ Route::group(['prefix' => 'api/v1', 'middleware' => 'json-exceptions'], function Route::group(['prefix' => 'api/web'], function() { Route::get('/taxonomies/all', 'Api\Web\TaxonomiesController@getAll'); - Route::get('/search', 'Api\Web\SearchController@getSearch'); + Route::get('/search', ['middleware' => ['auth', 'can:access-search'], 'Api\Web\SearchController@getSearch']); Route::get('/tracks', 'Api\Web\TracksController@getIndex'); Route::get('/tracks/{id}', 'Api\Web\TracksController@getShow')->where('id', '\d+'); diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 96b1b6c1..e01fb068 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -48,6 +48,10 @@ class AuthServiceProvider extends ServiceProvider */ public function boot(GateContract $gate) { + $gate->define('access-search', function(User $user) { + return $user->hasRole('admin') || $user->hasRole('moderator'); + }); + $gate->define('access-admin-area', function(User $user) { return $user->hasRole('admin'); }); diff --git a/resources/views/shared/_app_layout.blade.php b/resources/views/shared/_app_layout.blade.php index 0ad04930..ba8c52c0 100644 --- a/resources/views/shared/_app_layout.blade.php +++ b/resources/views/shared/_app_layout.blade.php @@ -66,7 +66,9 @@