Split CAPTCHA check and loading methods for easy integration into other parts of the site

This commit is contained in:
Kijin Sung 2023-06-25 19:56:00 +09:00
parent c0f9c77902
commit 4c9b14f077
2 changed files with 54 additions and 17 deletions

View file

@ -225,23 +225,7 @@ class spamfilterController extends spamfilter
function triggerCheckCaptcha(&$obj)
{
$config = ModuleModel::getModuleConfig('spamfilter');
if (!isset($config) || !isset($config->captcha) || !in_array($config->captcha->type, ['recaptcha', 'turnstile']) || !$config->captcha->site_key || !$config->captcha->secret_key)
{
return;
}
if ($this->user->is_admin === 'Y')
{
return;
}
if ($config->captcha->target_users !== 'everyone' && $this->user->member_srl)
{
return;
}
if ($config->captcha->target_frequency !== 'every_time' && isset($_SESSION['recaptcha_authenticated']) && $_SESSION['recaptcha_authenticated'])
{
return;
}
if (!$config->captcha->target_devices[Mobile::isFromMobilePhone() ? 'mobile' : 'pc'])
if (!SpamfilterModel::isCaptchaEnabled())
{
return;
}