fix(captcha): wire scene switches and rename menu to 人机验证

- Admin: 登录权限 → 人机验证; 停用场景 → 启用场景 (opt-in)
- Normalize enabled_scenarios with legacy disabled_scenarios BC
- Sign-in: never soft-bypass captcha; cancel unlocks button
- Captcha JS: cancel path finishes pending callback as false
This commit is contained in:
2026-07-15 16:48:57 +08:00
parent 808d46664f
commit bc96edf384
10 changed files with 143 additions and 54 deletions
@@ -282,6 +282,16 @@ class AKSRT_Admin_Schema_Provider {
}
}
// Captcha: always surface normalized enabled_scenarios (legacy disabled list inverted).
if ($option_key === 'aksrt_captcha_config' && function_exists('aksrt_get_captcha_config')) {
$normalized = aksrt_get_captcha_config();
foreach (['enabled', 'active_provider', 'enabled_scenarios', 'disabled_scenarios', 'tencent', 'aliyun', 'cloudflare', 'geetest', 'mode'] as $key) {
if (array_key_exists($key, $normalized)) {
$data[$key] = $normalized[$key];
}
}
}
return $data;
}
@@ -302,6 +312,24 @@ class AKSRT_Admin_Schema_Provider {
$stored[$key] = $value;
}
// Captcha: keep enabled_scenarios / disabled_scenarios mirrors in sync.
if ($option_key === 'aksrt_captcha_config' && function_exists('aksrt_captcha_scenes')) {
$all = array_keys(aksrt_captcha_scenes());
if (array_key_exists('enabled_scenarios', $stored)) {
$enabled = function_exists('aksrt_captcha_sanitize_scene_list')
? aksrt_captcha_sanitize_scene_list($stored['enabled_scenarios'])
: (array) $stored['enabled_scenarios'];
$stored['enabled_scenarios'] = $enabled;
$stored['disabled_scenarios'] = array_values(array_diff($all, $enabled));
} elseif (array_key_exists('disabled_scenarios', $stored)) {
$disabled = function_exists('aksrt_captcha_sanitize_scene_list')
? aksrt_captcha_sanitize_scene_list($stored['disabled_scenarios'])
: (array) $stored['disabled_scenarios'];
$stored['disabled_scenarios'] = $disabled;
$stored['enabled_scenarios'] = array_values(array_diff($all, $disabled));
}
}
$updated = update_option($option_key, $stored);
AKSRT_Settings::flush_settings_cache();