Ensure abuse hit counter is not increased for admin/API keys

This commit is contained in:
Jake Barnby 2022-08-31 15:50:53 +12:00
parent 1273f4c9b7
commit 8da011ad78
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -115,11 +115,14 @@ App::init()
;
}
$enabled = App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled';
if (
(App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled' // Route is rate-limited
&& $abuse->check()) // Abuse is not disabled
&& (!$isAppUser && !$isPrivilegedUser)
) { // User is not an admin or API key
$enabled // Abuse is enabled
&& !$isAppUser // User is not API key
&& !$isPrivilegedUser // User is not an admin
&& $abuse->check() // Route is rate-limited
) {
throw new Exception(Exception::GENERAL_RATE_LIMIT_EXCEEDED);
}
}