auth activity done
This commit is contained in:
46
app/Listeners/LoginListener.php
Normal file
46
app/Listeners/LoginListener.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoginListener
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
*/
|
||||
public function handle($event): void
|
||||
{
|
||||
$user = $event->user;
|
||||
|
||||
if (! $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::channel('auth_activity')
|
||||
->info(sprintf(
|
||||
'%s, APP_NAME: %s, REQUEST_TYPE: %s, SOURCE_IP: %s, SOURCE_PORT: %s, SOURCE_URL: %s, DESTINATION_IP: %s, DESTINATION_PORT: %s, DESTINATION_COUNTRY: %s',
|
||||
'LOGIN',
|
||||
config('app.name'),
|
||||
request()->method(),
|
||||
request()->ip(),
|
||||
$_SERVER['REMOTE_PORT'],
|
||||
request()->url(),
|
||||
request()->host(),
|
||||
request()->getPort(),
|
||||
'tk',
|
||||
));
|
||||
}
|
||||
}
|
||||
47
app/Listeners/LogoutListener.php
Normal file
47
app/Listeners/LogoutListener.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LogoutListener
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
$user = $event->user;
|
||||
|
||||
if (! $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::channel('auth_activity')
|
||||
->info(sprintf(
|
||||
'%s, APP_NAME: %s, REQUEST_TYPE: %s, SOURCE_IP: %s, SOURCE_PORT: %s, SOURCE_URL: %s, DESTINATION_IP: %s, DESTINATION_PORT: %s, DESTINATION_COUNTRY: %s',
|
||||
'LOGOUT',
|
||||
config('app.name'),
|
||||
request()->method(),
|
||||
request()->ip(),
|
||||
$_SERVER['REMOTE_PORT'],
|
||||
request()->url(),
|
||||
request()->host(),
|
||||
request()->getPort(),
|
||||
'tk',
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
@@ -15,9 +13,8 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => ['App\Listeners\LoginListener'],
|
||||
'Illuminate\Auth\Events\Logout' => ['App\Listeners\LogoutListener'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user