fix(captcha): seal comment fallback and phone-register client loop
Gate preprocess_comment so native wp-comments-post cannot bypass captcha, require verify+reset on phone register, and align UsersSignin status with active provider.
This commit is contained in:
1 parent
02f77b756c
commit
fa1ab52b8b
4 files changed
+66
-33
No files matched your search
@@ -81,6 +81,24 @@ class AKSRT_Moderation {
|
||||
* Main moderation entry.
|
||||
*/
|
||||
public function process(array $commentdata): array {
|
||||
|
||||
// 人机验证:覆盖 REST 与原生 wp-comments-post 两条提交合同(与审核开关无关)
|
||||
if (function_exists('aksrt_require_captcha')) {
|
||||
$payload = is_array($_POST ?? null) ? wp_unslash($_POST) : [];
|
||||
if (isset($payload['captcha']) && is_array($payload['captcha'])) {
|
||||
$payload = array_merge($payload, $payload['captcha']);
|
||||
}
|
||||
$captcha_result = aksrt_require_captcha('comment', $payload);
|
||||
if ($captcha_result !== true) {
|
||||
$msg = is_string($captcha_result) ? $captcha_result : __('人机验证失败', 'aksrt');
|
||||
wp_die(
|
||||
esc_html($msg),
|
||||
esc_html__('评论提交失败', 'aksrt'),
|
||||
['response' => 400, 'back_link' => true]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$config = $this->get_config();
|
||||
|
||||
if (empty($config['enabled'])) {
|
||||
|
||||
@@ -92,12 +92,9 @@ add_action('pre_get_posts', function ($query) {
|
||||
// ============================================================
|
||||
// 评论提交:单一合同
|
||||
// ------------------------------------------------------------
|
||||
// 评论提交统一走 WordPress 原生 wp-comments-post.php,由前端
|
||||
// main.js initCommentSystem() 以 AJAX 拦截:它负责人机验证、频率
|
||||
// 限制、审核管线,并在成功后通过 reloadCommentList() 重新拉取,
|
||||
// 列表仍由 aksrt_comment_callback 这一规范渲染器输出。
|
||||
// 不再保留并行的 aksrt_submit_comment 动作(避免绕过验证码的第二套提交合同)。
|
||||
// 详见 comment-contract.md。
|
||||
// 主路径:前端 comments.js → REST /comment/submit(aksrt_require_captcha)。
|
||||
// 兜底 / 原生 wp-comments-post.php 经 preprocess_comment 做人机验证,避免绕过。
|
||||
// 列表仍由 aksrt_comment_callback 统一渲染。
|
||||
// ============================================================
|
||||
|
||||
// ============================================================
|
||||
|
||||
Reference in new issue
Block a user