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:
1 parent
808d46664f
commit
bc96edf384
10 files changed
+143
-54
No files matched your search
+22
-14
@@ -114,14 +114,28 @@
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function triggerCaptcha(callback) {
|
||||
function triggerCaptcha(onSuccess, onFail) {
|
||||
var mount = document.querySelector('[data-signin-captcha]');
|
||||
var state = window.AKSRTCaptchaState;
|
||||
var scene = state && state.scenes && state.scenes.signin;
|
||||
|
||||
if (scene && typeof scene.verify === 'function') {
|
||||
scene.verify(callback);
|
||||
scene.verify(function (ok) {
|
||||
if (ok === false) {
|
||||
if (typeof onFail === 'function') onFail('已取消验证');
|
||||
return;
|
||||
}
|
||||
onSuccess();
|
||||
});
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
|
||||
if (mount) {
|
||||
if (typeof onFail === 'function') onFail('人机验证加载中,请稍候再试');
|
||||
return;
|
||||
}
|
||||
|
||||
onSuccess();
|
||||
}
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
@@ -129,19 +143,13 @@
|
||||
btn.innerHTML = '…';
|
||||
setTip('');
|
||||
|
||||
var captchaDone = false;
|
||||
var timeoutId = setTimeout(function () {
|
||||
if (!captchaDone) {
|
||||
captchaDone = true;
|
||||
doSignin();
|
||||
}
|
||||
}, 30000);
|
||||
|
||||
triggerCaptcha(function () {
|
||||
clearTimeout(timeoutId);
|
||||
if (captchaDone) return;
|
||||
captchaDone = true;
|
||||
doSignin();
|
||||
}, function (msg) {
|
||||
resetCaptcha();
|
||||
if (msg) setTip(msg);
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '签到';
|
||||
});
|
||||
|
||||
function doSignin() {
|
||||
|
||||
Reference in new issue
Block a user