2018-07-16 23:49:08 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Listeners;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
2019-03-13 20:12:03 -07:00
|
|
|
use DB;
|
|
|
|
use Illuminate\Auth\Events\Failed;
|
2018-07-16 23:49:08 -07:00
|
|
|
|
|
|
|
class LogFailedLogin
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create the event listener.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the event.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Auth\Events\Failed $event
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle(Failed $event)
|
|
|
|
{
|
|
|
|
$now = new Carbon();
|
|
|
|
try {
|
|
|
|
DB::table('login_attempts')->insert(
|
|
|
|
[
|
|
|
|
'username' => $event->credentials['username'],
|
|
|
|
'user_agent' => request()->header('User-Agent'),
|
|
|
|
'remote_ip' => request()->ip(),
|
|
|
|
'successful' => 0,
|
2018-07-17 01:03:32 -07:00
|
|
|
'created_at' => $now,
|
2018-07-16 23:49:08 -07:00
|
|
|
]
|
|
|
|
);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
\Log::debug($e);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|