From c22233255f2cedc686e770067e38d474c8d86e93 Mon Sep 17 00:00:00 2001 From: Muhammad Jawad Date: Tue, 25 Oct 2022 16:08:21 +0500 Subject: [PATCH] Protected the routes with middlewares and added middleware option in config --- src/config.php | 5 ++++- src/routes/grapesjs.php | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/config.php b/src/config.php index b00cf8a..3b401ca 100644 --- a/src/config.php +++ b/src/config.php @@ -6,5 +6,8 @@ 'force_class' => false, 'fonts' => [], 'styles' => [], - 'scripts' => [] + 'scripts' => [], + 'middleware' => [ + 'web', 'auth' + ], ]; \ No newline at end of file diff --git a/src/routes/grapesjs.php b/src/routes/grapesjs.php index 8b6ddd6..8b9dc15 100644 --- a/src/routes/grapesjs.php +++ b/src/routes/grapesjs.php @@ -3,12 +3,16 @@ use Illuminate\Support\Facades\Route; -Route::prefix('grapesjs')->name('grapesjs.')->namespace('Dotlogics\Grapesjs\App\Http\Controllers')->group(function(){ - Route::post('editor/asset/store', 'AssetController@store')->name('editor.asset.store'); - - Route::get('editor/{model}/{editable}', 'EditorController@editor')->name('editor.model.editor'); - Route::post('editor/{model}/{editable}', 'EditorController@store')->name('editor.model.store'); - - Route::get('editor/{model}/{editable}/templates', 'EditorController@templates')->name('editor.model.templates'); - Route::get('editor/templates', 'EditorController@templates')->name('editor.templates'); -}); +Route::prefix('grapesjs') + ->name('grapesjs.') + ->namespace('Dotlogics\Grapesjs\App\Http\Controllers') + ->middleware(config('grapesjs.middleware', [])) + ->group(function(){ + Route::post('editor/asset/store', 'AssetController@store')->name('editor.asset.store'); + + Route::get('editor/{model}/{editable}', 'EditorController@editor')->name('editor.model.editor'); + Route::post('editor/{model}/{editable}', 'EditorController@store')->name('editor.model.store'); + + Route::get('editor/{model}/{editable}/templates', 'EditorController@templates')->name('editor.model.templates'); + Route::get('editor/templates', 'EditorController@templates')->name('editor.templates'); + });