Authored by yyq

img verity 204

... ... @@ -117,6 +117,12 @@ const submitValidate = {
yield self.clearLimitIp(req);
// 图形验证码关闭时通过极验证后解锁接口风控
if (req.session.apiRiskClear) {
delete req.session.apiRiskClear;
yield req.ctx(checkModel).verifyImgCheckRisk(req.cookies.udid, '1,2,3,4').catch(console.error);
}
return res.json({
code: 200
});
... ...
... ... @@ -52,6 +52,19 @@ exports.imgCheckRisk = (req, res, next) => {
'X-Forwarded-For': req.yoho.clientIp || '',
'User-Agent': 'yoho/nodejs'
}
}).on('response', response => {
// status code 204 接口关闭图形验证码,通过cookie通知验证页刷行切换验证方式
if (response.statusCode === 204) {
res.cookie('refresh_page', 1, {
path: '/',
maxAge: 60000
});
delete req.session.apiRiskValidate;
req.session.apiRiskClear = true;
return res.json({code: 204});
}
}).pipe(res); // eslint-disable-line
}).catch(next);
};
... ...
... ... @@ -24,6 +24,17 @@ let validate = new Validate($check, validateOptions);
validate.init();
$(function() {
// 定时监测cookie中refresh_page刷新页面也换验证方式
setInterval(function() {
if (window.cookie('refresh_page') > 0) {
window.setCookie('refresh_page', 0, {
path: '/'
});
window.location.reload();
}
}, 1000);
$('.submit').on('click', function() {
validate.getResults().then((result) => {
$.extend(result, baseInfo);
... ...