Skip to content

Commit

Permalink
Merge pull request #1 from lamalamaNL/analysis-2QYr6P
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
lamalamaMark committed Jun 2, 2020
2 parents 803a410 + 5f82729 commit be5caf2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/Console/Commands/ClearLoginAttempts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace LamaLama\LoginAttempts\Console\Commands;

use Skata\Kernel\Models\Orders\Shipment;
use Illuminate\Console\Command;

class ClearLoginAttempts extends Command
Expand Down
15 changes: 7 additions & 8 deletions src/Listeners/RecordFailedLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace LamaLama\LoginAttempts\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use LamaLama\LoginAttempts\Events\AuthFailed;
use LamaLama\LoginAttempts\Models\LoginAttempt;

class RecordFailedLoginAttempt
class RecordFailedLogin
{
/**
* Create the event listener.
Expand All @@ -22,20 +20,21 @@ public function __construct()
/**
* Handle the event.
*
* @param AuthFailed $event
* @param AuthFailed $event
*
* @return void
*/
public function handle(AuthFailed $event)
{
if (! config('login-attempts.record_failed_login')) {
if (!config('login-attempts.record_failed_login')) {
return;
}

LoginAttempt::create([
'event' => 'failed',
'event' => 'failed',
'user_id' => null,
'email' => $event->user->email,
'ip' => request()->ip()
'email' => $event->user->email,
'ip' => request()->ip(),
]);
}
}
17 changes: 8 additions & 9 deletions src/Listeners/RecordSuccesfullLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
use App\Models\LoginAttempt;
use App\Models\User;
use App\Notifications\LoginFromNewIpDetected;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Notification;
use Torann\GeoIP\Facades\GeoIP;

class RecordSuccesfullLoginAttempt
class RecordSuccesfullLogin
{
/**
* Create the event listener.
Expand All @@ -26,12 +24,13 @@ public function __construct()
/**
* Handle the event.
*
* @param AuthSucceeded $event
* @param AuthSucceeded $event
*
* @return void
*/
public function handle(AuthSucceeded $event)
{
if (! config('login-attempts.record_successful_login')) {
if (!config('login-attempts.record_successful_login')) {
return;
}

Expand All @@ -40,7 +39,7 @@ public function handle(AuthSucceeded $event)
->get();

if ($loginAttempts->isEmpty()) {
$users = User::whereHas('roles', function($q) {
$users = User::whereHas('roles', function ($q) {
$q->where('name', 'owner');
})->get();

Expand All @@ -49,10 +48,10 @@ public function handle(AuthSucceeded $event)
}

LoginAttempt::create([
'event' => 'succeeded',
'event' => 'succeeded',
'user_id' => $event->user->id,
'email' => $event->user->email,
'ip' => request()->ip()
'email' => $event->user->email,
'ip' => request()->ip(),
]);
}
}
3 changes: 1 addition & 2 deletions src/LoginAttemptsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace LamaLama\LoginAttempts;

use Illuminate\Support\ServiceProvider;
use LamaLama\LoginAttempts\LoginAttempts;
use LamaLama\LoginAttempts\Console\Commands\ClearLoginAttempts;

class LoginAttemptsServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -32,7 +31,7 @@ protected function registerPublishables(): void
__DIR__.'/../config/login-attempts.php' => config_path('login-attempts.php'),
], 'config');

if (! class_exists('CreateWishlistTable')) {
if (!class_exists('CreateWishlistTable')) {
$this->publishes([
__DIR__.'/../database/migrations/create_login_attempts_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_login_attempts_table.php'),
], 'migrations');
Expand Down

0 comments on commit be5caf2

Please sign in to comment.