1
0
Fork 0
pixelfed/app/Listeners/LogFailedLogin.php

49 lines
948 B
PHP
Raw Normal View History

2018-09-16 00:36:04 +00:00
<?php
namespace App\Listeners;
use App\AccountLog;
use App\User;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogFailedLogin
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
$user = $event->user;
$request = request();
2018-11-29 22:30:38 +00:00
if(!$user) {
return;
}
2018-09-16 00:36:04 +00:00
$log = new AccountLog();
$log->user_id = $user->id;
$log->item_id = $user->id;
$log->item_type = 'App\User';
$log->action = 'auth.failed';
$log->message = 'Failed login attempt';
$log->link = null;
$log->ip_address = $request->ip();
$log->user_agent = $request->userAgent();
$log->save();
}
}