Skip to content
Snippets Groups Projects
Commit 55fc047a authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Catching connection error to redis cache in middleware

parent 58f85ea1
No related branches found
No related tags found
3 merge requests!1645Development,!1643Development,!1630Resolve "Make the Cache connection optional"
...@@ -7,6 +7,7 @@ use Captcha; ...@@ -7,6 +7,7 @@ use Captcha;
use Closure; use Closure;
use Cookie; use Cookie;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Log;
use URL; use URL;
class HumanVerification class HumanVerification
...@@ -66,7 +67,6 @@ class HumanVerification ...@@ -66,7 +67,6 @@ class HumanVerification
} else { } else {
$user = $users[$uid]; $user = $users[$uid];
} }
# Lock out everyone in a Bot network # Lock out everyone in a Bot network
# Find out how many requests this IP has made # Find out how many requests this IP has made
$sum = 0; $sum = 0;
...@@ -130,8 +130,10 @@ class HumanVerification ...@@ -130,8 +130,10 @@ class HumanVerification
} }
} }
} catch (\Exception $e) {
Log::error($e->getMessage());
} finally { } finally {
if ($update) { if ($update && $user != null) {
if ($user["whitelist"]) { if ($user["whitelist"]) {
$user["expiration"] = now()->addWeeks(2); $user["expiration"] = now()->addWeeks(2);
} else { } else {
...@@ -148,7 +150,6 @@ class HumanVerification ...@@ -148,7 +150,6 @@ class HumanVerification
public function setUser($prefix, $user) public function setUser($prefix, $user)
{ {
// Lock must be acquired within 2 seconds
$userList = Cache::get($prefix . "." . $user["id"], []); $userList = Cache::get($prefix . "." . $user["id"], []);
$userList[$user["uid"]] = $user; $userList[$user["uid"]] = $user;
Cache::put($prefix . "." . $user["id"], $userList, 2 * 7 * 24 * 60 * 60); Cache::put($prefix . "." . $user["id"], $userList, 2 * 7 * 24 * 60 * 60);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment