From 5e60d1e0bd6c361ee8a581936bcc4a0cea426e00 Mon Sep 17 00:00:00 2001 From: noor Date: Tue, 21 Mar 2023 12:38:03 +0530 Subject: [PATCH] fixes Apply fixes from StyleCI changes array key fix --- app/Http/Controllers/Auth/AuthController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index d1d9fb892..0931fac95 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -486,11 +486,17 @@ class AuthController extends Controller $time = $security->lockout_period; $max_attempts = $security->backlist_threshold; $table = 'login_attempts'; - $result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL '.$time.' MINUTE)>NOW() then 1 else 0 end) as Denied '. - ' FROM '.$table." WHERE IP = '$value' OR User = '$field'"); + $result = DB::table($table) + ->select('Attempts', DB::raw('(CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL ? MINUTE) > NOW() then 1 else 0 end) as Denied')) + ->where(function ($query) use ($value, $field) { + $query->where('IP', '=', $value) + ->orWhere('User', '=', $field); + }) + ->setBindings([$time, $value, $field]) + ->get(); $data = $result; //Verify that at least one login attempt is in database - if (!$data) { + if (count($data) == 0) { return 0; } if ($data[0]->Attempts >= $max_attempts) {