Authored by yyq

img verity 204

@@ -117,6 +117,12 @@ const submitValidate = { @@ -117,6 +117,12 @@ const submitValidate = {
117 117
118 yield self.clearLimitIp(req); 118 yield self.clearLimitIp(req);
119 119
  120 + // 图形验证码关闭时通过极验证后解锁接口风控
  121 + if (req.session.apiRiskClear) {
  122 + delete req.session.apiRiskClear;
  123 + yield req.ctx(checkModel).verifyImgCheckRisk(req.cookies.udid, '1,2,3,4').catch(console.error);
  124 + }
  125 +
120 return res.json({ 126 return res.json({
121 code: 200 127 code: 200
122 }); 128 });
@@ -52,6 +52,19 @@ exports.imgCheckRisk = (req, res, next) => { @@ -52,6 +52,19 @@ exports.imgCheckRisk = (req, res, next) => {
52 'X-Forwarded-For': req.yoho.clientIp || '', 52 'X-Forwarded-For': req.yoho.clientIp || '',
53 'User-Agent': 'yoho/nodejs' 53 'User-Agent': 'yoho/nodejs'
54 } 54 }
  55 + }).on('response', response => {
  56 + // status code 204 接口关闭图形验证码,通过cookie通知验证页刷行切换验证方式
  57 + if (response.statusCode === 204) {
  58 + res.cookie('refresh_page', 1, {
  59 + path: '/',
  60 + maxAge: 60000
  61 + });
  62 +
  63 + delete req.session.apiRiskValidate;
  64 + req.session.apiRiskClear = true;
  65 +
  66 + return res.json({code: 204});
  67 + }
55 }).pipe(res); // eslint-disable-line 68 }).pipe(res); // eslint-disable-line
56 }).catch(next); 69 }).catch(next);
57 }; 70 };
@@ -24,6 +24,17 @@ let validate = new Validate($check, validateOptions); @@ -24,6 +24,17 @@ let validate = new Validate($check, validateOptions);
24 validate.init(); 24 validate.init();
25 25
26 $(function() { 26 $(function() {
  27 +
  28 + // 定时监测cookie中refresh_page刷新页面也换验证方式
  29 + setInterval(function() {
  30 + if (window.cookie('refresh_page') > 0) {
  31 + window.setCookie('refresh_page', 0, {
  32 + path: '/'
  33 + });
  34 + window.location.reload();
  35 + }
  36 + }, 1000);
  37 +
27 $('.submit').on('click', function() { 38 $('.submit').on('click', function() {
28 validate.getResults().then((result) => { 39 validate.getResults().then((result) => {
29 $.extend(result, baseInfo); 40 $.extend(result, baseInfo);