diff --git a/app/Http/Middleware/HumanVerification.php b/app/Http/Middleware/HumanVerification.php index f1416ffa33ff1d703f9bc1599c2d6d2893595f5a..2a69dc31c564d0337c5f7ceebadb0cde4a972c40 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"]]);