fix(captcha): wait for runtime before sign-in
This commit is contained in:
1 parent
9d458dd99a
commit
a0adddce59
3 files changed
+85
-4
No files matched your search
+27
-4
@@ -6,7 +6,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (!window.aksrtData || !window.AksrtRequest) {
|
||||
if (!window.aksrtData) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,14 +132,27 @@
|
||||
|
||||
signinBusy = true;
|
||||
setButtonState('busy');
|
||||
var captchaRequired = !!window.aksrtData.captchaSignin;
|
||||
var captcha = window.AKSRTCaptcha;
|
||||
var mount = captchaMount();
|
||||
(captcha ? captcha.run('signin', mount) : Promise.resolve({})).then(function (payload) {
|
||||
|
||||
if (captchaRequired && (!captcha || !mount)) {
|
||||
signinBusy = false;
|
||||
notyf('人机验证未正确加载,请刷新页面后重试', 'danger');
|
||||
setButtonState('idle');
|
||||
return;
|
||||
}
|
||||
if (!captchaRequired) {
|
||||
doSignin({});
|
||||
return;
|
||||
}
|
||||
|
||||
captcha.run('signin', mount).then(function (payload) {
|
||||
if (payload === null) throw new Error('已取消验证');
|
||||
doSignin(payload);
|
||||
}).catch(function (error) {
|
||||
signinBusy = false;
|
||||
if (captcha) captcha.reset('signin', mount);
|
||||
captcha.reset('signin', mount);
|
||||
notyf((error && error.message) || '人机验证加载中,请稍候再试', 'danger');
|
||||
setButtonState('idle');
|
||||
});
|
||||
@@ -149,5 +162,15 @@
|
||||
refresh();
|
||||
}
|
||||
|
||||
jQuery(document).off('auto_fun.aksrt-signin').on('auto_fun.aksrt-signin', initSignin);
|
||||
function boot() {
|
||||
if (!window.AksrtRequest) return;
|
||||
jQuery(document).off('auto_fun.aksrt-signin').on('auto_fun.aksrt-signin', initSignin);
|
||||
initSignin();
|
||||
}
|
||||
|
||||
if (typeof tbquire === 'function') {
|
||||
tbquire(['main'], boot);
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user