Skip to content

Commit 3988f8e

Browse files
committed
Update LaravelUserMonitoringEventServiceProvider.php
1 parent 387cb97 commit 3988f8e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/Providers/LaravelUserMonitoringEventServiceProvider.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@ public function boot()
1818
$table = config('user-monitoring.authentication_monitoring.table');
1919

2020
// Login Event
21-
Event::listen(function (Login $event) use ($agent, $guard, $table) {
22-
DB::table($table)
23-
->insert(
24-
$this->insertData($guard, $agent, 'login'),
25-
);
26-
});
21+
if (config('user-monitoring.authentication_monitoring.on_login', false)) {
22+
Event::listen(function (Login $event) use ($agent, $guard, $table) {
23+
DB::table($table)
24+
->insert(
25+
$this->insertData($guard, $agent, 'login'),
26+
);
27+
});
28+
}
2729

2830
// Logout Event
29-
Event::listen(function (Logout $event) use ($agent, $guard, $table) {
30-
DB::table($table)
31-
->insert(
32-
$this->insertData($guard, $agent, 'logout'),
33-
);
34-
});
31+
if (config('user-monitoring.authentication_monitoring.on_logout', false)) {
32+
Event::listen(function (Logout $event) use ($agent, $guard, $table) {
33+
DB::table($table)
34+
->insert(
35+
$this->insertData($guard, $agent, 'logout'),
36+
);
37+
});
38+
}
3539
}
3640

3741
/**
@@ -56,4 +60,4 @@ private function insertData(string $guard, Agent $agent, string $actionType): ar
5660
'updated_at' => now(),
5761
];
5862
}
59-
}
63+
}

0 commit comments

Comments
 (0)