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
+43
-25
@@ -205,35 +205,53 @@
|
||||
submitBtn.textContent = '注册中...'
|
||||
}
|
||||
|
||||
const captchaData = collectCaptchaFields(form)
|
||||
|
||||
fetch(REST_BASE + '/auth/phone-register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ phone, code, password, invite_code: inviteCode, ...captchaData }),
|
||||
})
|
||||
.then(r => r.json().then(data => ({ ok: r.ok, data })))
|
||||
.then(({ ok, data }) => {
|
||||
if (ok && data.success) {
|
||||
showToast(data.message || '注册成功', 'success')
|
||||
setTimeout(() => {
|
||||
window.location.href = data.data?.redirect || '/'
|
||||
}, 500)
|
||||
} else {
|
||||
showToast(data.message || '注册失败', 'error')
|
||||
const captchaState = window.AKSRTCaptchaState
|
||||
const doRegister = () => {
|
||||
const captchaData = collectCaptchaFields(form)
|
||||
fetch(REST_BASE + '/auth/phone-register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ phone, code, password, invite_code: inviteCode, ...captchaData }),
|
||||
})
|
||||
.then(r => r.json().then(data => ({ ok: r.ok, data })))
|
||||
.then(({ ok, data }) => {
|
||||
if (ok && data.success) {
|
||||
showToast(data.message || '注册成功', 'success')
|
||||
setTimeout(() => {
|
||||
window.location.href = data.data?.redirect || '/'
|
||||
}, 500)
|
||||
} else {
|
||||
showToast(data.message || '注册失败', 'error')
|
||||
try {
|
||||
if (captchaState && captchaState.scenes && captchaState.scenes.register) {
|
||||
captchaState.scenes.register.reset()
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = false
|
||||
submitBtn.textContent = '注册'
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
showToast('网络错误', 'error')
|
||||
try {
|
||||
if (captchaState && captchaState.scenes && captchaState.scenes.register) {
|
||||
captchaState.scenes.register.reset()
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = false
|
||||
submitBtn.textContent = '注册'
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
showToast('网络错误', 'error')
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = false
|
||||
submitBtn.textContent = '注册'
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (captchaState && captchaState.scenes && captchaState.scenes.register) {
|
||||
captchaState.scenes.register.verify(doRegister)
|
||||
} else {
|
||||
doRegister()
|
||||
}
|
||||
}
|
||||
|
||||
function handlePhoneLogin(form) {
|
||||
|
||||
Reference in new issue
Block a user