From 387cb97abfe465e18c67df5eb0ae555df69b429e Mon Sep 17 00:00:00 2001 From: miladev-ent <98118400+milwad-dev@users.noreply.github.com> Date: Tue, 1 Aug 2023 02:40:57 +0330 Subject: [PATCH 1/2] Update user-monitoring.php --- config/user-monitoring.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/user-monitoring.php b/config/user-monitoring.php index 299422d..6db30f7 100644 --- a/config/user-monitoring.php +++ b/config/user-monitoring.php @@ -64,5 +64,11 @@ * If you want to delete authentications-monitoring rows when the user is deleted from the users table you can set true or false. */ 'delete_user_record_when_user_delete' => true, + + /* + * You can set true/false for monitor login or logout. + */ + 'on_login' => true, + 'on_logout' => true, ], ]; From 3988f8e2062656c5d67abb0783cb9a91c2514271 Mon Sep 17 00:00:00 2001 From: miladev-ent <98118400+milwad-dev@users.noreply.github.com> Date: Tue, 1 Aug 2023 02:42:12 +0330 Subject: [PATCH 2/2] Update LaravelUserMonitoringEventServiceProvider.php --- ...avelUserMonitoringEventServiceProvider.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Providers/LaravelUserMonitoringEventServiceProvider.php b/src/Providers/LaravelUserMonitoringEventServiceProvider.php index 2b8ae7b..d2cae48 100644 --- a/src/Providers/LaravelUserMonitoringEventServiceProvider.php +++ b/src/Providers/LaravelUserMonitoringEventServiceProvider.php @@ -18,20 +18,24 @@ public function boot() $table = config('user-monitoring.authentication_monitoring.table'); // Login Event - Event::listen(function (Login $event) use ($agent, $guard, $table) { - DB::table($table) - ->insert( - $this->insertData($guard, $agent, 'login'), - ); - }); + if (config('user-monitoring.authentication_monitoring.on_login', false)) { + Event::listen(function (Login $event) use ($agent, $guard, $table) { + DB::table($table) + ->insert( + $this->insertData($guard, $agent, 'login'), + ); + }); + } // Logout Event - Event::listen(function (Logout $event) use ($agent, $guard, $table) { - DB::table($table) - ->insert( - $this->insertData($guard, $agent, 'logout'), - ); - }); + if (config('user-monitoring.authentication_monitoring.on_logout', false)) { + Event::listen(function (Logout $event) use ($agent, $guard, $table) { + DB::table($table) + ->insert( + $this->insertData($guard, $agent, 'logout'), + ); + }); + } } /** @@ -56,4 +60,4 @@ private function insertData(string $guard, Agent $agent, string $actionType): ar 'updated_at' => now(), ]; } -} \ No newline at end of file +}