From c63bc9f57a589d226d5b3bfd4ab0c157ac8bd3b1 Mon Sep 17 00:00:00 2001 From: Iachi Dimitri Fabien Date: Tue, 26 Jul 2022 14:16:07 +0200 Subject: [PATCH] Allow unauthenticated access to logger activity screens --- src/App/Http/Controllers/LaravelLoggerController.php | 5 ++++- src/routes/web.php | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/App/Http/Controllers/LaravelLoggerController.php b/src/App/Http/Controllers/LaravelLoggerController.php index 92c2f0a..6e093f5 100644 --- a/src/App/Http/Controllers/LaravelLoggerController.php +++ b/src/App/Http/Controllers/LaravelLoggerController.php @@ -28,7 +28,10 @@ class LaravelLoggerController extends BaseController */ public function __construct() { - $this->middleware('auth'); + $this->_authRequired = config('LaravelLogger.authRequired'); + if ($this->_authRequired) { + $this->middleware('auth'); + } $this->_rolesEnabled = config('LaravelLogger.rolesEnabled'); $this->_rolesMiddlware = config('LaravelLogger.rolesMiddlware'); diff --git a/src/routes/web.php b/src/routes/web.php index 3688007..29b8032 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -7,8 +7,15 @@ | */ -Route::group(['prefix' => 'activity', 'namespace' => 'jeremykenedy\LaravelLogger\App\Http\Controllers', 'middleware' => ['web', 'auth', 'activity']], function () { +Route::group(['prefix' => 'activity', 'namespace' => 'jeremykenedy\LaravelLogger\App\Http\Controllers', 'middleware' => (function () { + $middleware = ['web', 'activity']; + if (config('LaravelLogger.authRequired', true)) { + $middleware[] = 'auth'; + } + + return $middleware; +})], function () { // Dashboards Route::get('/', 'LaravelLoggerController@showAccessLog')->name('activity'); Route::get('/cleared', ['uses' => 'LaravelLoggerController@showClearedActivityLog'])->name('cleared');