From 597c48bc01e2b838ff2faffbea7de741dda8b535 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Thu, 4 Oct 2018 12:39:59 +0200 Subject: [PATCH] Bugfix for when a key is entered --- app/Http/Middleware/HumanVerification.php | 54 ++++++++++++----------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/app/Http/Middleware/HumanVerification.php b/app/Http/Middleware/HumanVerification.php index f1416ffa3..2a69dc31c 100644 --- a/app/Http/Middleware/HumanVerification.php +++ b/app/Http/Middleware/HumanVerification.php @@ -23,6 +23,7 @@ class HumanVerification // The specific user $user = null; $newUser = true; + $update = true; try { $id = hash("sha512", $request->ip()); $uid = hash("sha512", $request->ip() . $_SERVER["AGENT"]); @@ -35,6 +36,7 @@ class HumanVerification * might have to change it at some point. */ if ($request->filled('password') || $request->filled('key') || $request->filled('appversion') || !env('BOT_PROTECTION', false)) { + $update = false; return $next($request); } @@ -134,32 +136,34 @@ class HumanVerification // Failure in contacting metager3.de } finally { // Update the user in the database - if($newUser){ - DB::table('humanverification')->insert( - [ - 'uid' => $user["uid"], - 'id' => $user["id"], - 'unusedResultPages' => $user['unusedResultPages'], - 'whitelist' => $user["whitelist"], - 'whitelistCounter' => $user["whitelistCounter"], - 'locked' => $user["locked"], - "lockedKey" => $user["lockedKey"], - 'updated_at' => $user["updated_at"], - ] - ); - }else{ - DB::table('humanverification')->where('uid', $uid)->update( - [ - 'uid' => $user["uid"], - 'id' => $user["id"], - 'unusedResultPages' => $user['unusedResultPages'], - 'whitelist' => $user["whitelist"], - 'whitelistCounter' => $user["whitelistCounter"], - 'locked' => $user["locked"], - "lockedKey" => $user["lockedKey"], - 'updated_at' => $user["updated_at"], - ] + if($update){ + if($newUser){ + DB::table('humanverification')->insert( + [ + 'uid' => $user["uid"], + 'id' => $user["id"], + 'unusedResultPages' => $user['unusedResultPages'], + 'whitelist' => $user["whitelist"], + 'whitelistCounter' => $user["whitelistCounter"], + 'locked' => $user["locked"], + "lockedKey" => $user["lockedKey"], + 'updated_at' => $user["updated_at"], + ] ); + }else{ + DB::table('humanverification')->where('uid', $uid)->update( + [ + 'uid' => $user["uid"], + 'id' => $user["id"], + 'unusedResultPages' => $user['unusedResultPages'], + 'whitelist' => $user["whitelist"], + 'whitelistCounter' => $user["whitelistCounter"], + 'locked' => $user["locked"], + "lockedKey" => $user["lockedKey"], + 'updated_at' => $user["updated_at"], + ] + ); + } } } $request->request->add(['verification_id' => $user["uid"], 'verification_count' => $user["unusedResultPages"]]); -- GitLab