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;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Auth\Events\Registered;
|
|
||||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
@@ -15,9 +13,8 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
* @var array<class-string, array<int, class-string>>
|
* @var array<class-string, array<int, class-string>>
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
Registered::class => [
|
'Illuminate\Auth\Events\Login' => ['App\Listeners\LoginListener'],
|
||||||
SendEmailVerificationNotification::class,
|
'Illuminate\Auth\Events\Logout' => ['App\Listeners\LogoutListener'],
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -127,6 +127,13 @@ return [
|
|||||||
'path' => storage_path('logs/laravel.log'),
|
'path' => storage_path('logs/laravel.log'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'auth_activity' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/auth_activity.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
'halkbank_payment_error' => [
|
'halkbank_payment_error' => [
|
||||||
'driver' => 'single',
|
'driver' => 'single',
|
||||||
'path' => storage_path('logs/halkbank_payment_error.log'),
|
'path' => storage_path('logs/halkbank_payment_error.log'),
|
||||||
|
|||||||
Reference in New Issue
Block a user