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

more friendly captcha to large networks

parent e9546fc2
No related branches found
No related tags found
1 merge request!1980Resolve "Browserverification"
...@@ -75,8 +75,12 @@ class HumanVerification ...@@ -75,8 +75,12 @@ class HumanVerification
$refererLock = $user->refererLock(); $refererLock = $user->refererLock();
/**
if ((!$user->alone && $user->request_count_all_users >= 50 && !$user["whitelist"]) || $refererLock) { * Directly lock any user when there are many not whitelisted accounts on this IP
* Only applies when the user itself is not whitelisted.
* Also applies RefererLock from above
*/
if ((!$user->alone && $user->request_count_all_users >= 50 && !$user->isWhiteListed() && $user->not_whitelisted_accounts > $user->whitelisted_accounts) || $refererLock) {
$user->lockUser(); $user->lockUser();
} }
......
...@@ -15,6 +15,8 @@ class HumanVerification ...@@ -15,6 +15,8 @@ class HumanVerification
public readonly ?string $id; public readonly ?string $id;
public readonly ?string $uid; public readonly ?string $uid;
public readonly ?bool $alone; public readonly ?bool $alone;
public readonly ?int $whitelisted_accounts;
public readonly ?int $not_whitelisted_accounts;
public int $request_count_all_users = 0; public int $request_count_all_users = 0;
public function __construct() public function __construct()
...@@ -64,16 +66,23 @@ class HumanVerification ...@@ -64,16 +66,23 @@ class HumanVerification
$sum = 0; $sum = 0;
// Defines if this is the only user using that IP Adress // Defines if this is the only user using that IP Adress
$alone = true; $alone = true;
$whitelisted_accounts = 0;
$not_whitelisted_accounts = 0;
foreach ($this->users as $uidTmp => $userTmp) { foreach ($this->users as $uidTmp => $userTmp) {
if (!$userTmp["whitelist"]) { if (!$userTmp["whitelist"]) {
$not_whitelisted_accounts++;
$sum += $userTmp["unusedResultPages"]; $sum += $userTmp["unusedResultPages"];
if ($userTmp["uid"] !== $uid) { if ($userTmp["uid"] !== $uid) {
$alone = false; $alone = false;
} }
} else {
$whitelisted_accounts++;
} }
} }
$this->alone = $alone; $this->alone = $alone;
$this->request_count_all_users = $sum; $this->request_count_all_users = $sum;
$this->whitelisted_accounts = $whitelisted_accounts;
$this->not_whitelisted_accounts = $not_whitelisted_accounts;
} }
function lockUser() function lockUser()
...@@ -155,6 +164,11 @@ class HumanVerification ...@@ -155,6 +164,11 @@ class HumanVerification
} }
} }
public function isWhiteListed()
{
return $this->user["whitelist"];
}
function addQuery() function addQuery()
{ {
$this->user["unusedResultPages"]++; $this->user["unusedResultPages"]++;
......
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