Authored by 陈峰

Merge branch 'feature/superpwd' into 'gray'

geetest增加超级密码



See merge request !400
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 const _ = require('lodash'); 2 const _ = require('lodash');
3 const Geetest = require('geetest'); 3 const Geetest = require('geetest');
4 const logger = global.yoho.logger; 4 const logger = global.yoho.logger;
  5 +const config = global.yoho.config;
5 6
6 const captcha = new Geetest({ 7 const captcha = new Geetest({
7 geetest_id: 'bce95d796bc3058615fdf2ec2c0aef29', 8 geetest_id: 'bce95d796bc3058615fdf2ec2c0aef29',
@@ -26,7 +27,8 @@ const geetest = { @@ -26,7 +27,8 @@ const geetest = {
26 validate(req, res, next) { 27 validate(req, res, next) {
27 let challenge = req.body.geetest_challenge, 28 let challenge = req.body.geetest_challenge,
28 validate = req.body.geetest_validate, 29 validate = req.body.geetest_validate,
29 - seccode = req.body.geetest_seccode; 30 + seccode = req.body.geetest_seccode,
  31 + testCode = req.body.yohobuy;
30 32
31 let errRes = { 33 let errRes = {
32 code: 400, 34 code: 400,
@@ -35,6 +37,10 @@ const geetest = { @@ -35,6 +37,10 @@ const geetest = {
35 changeCaptcha: true 37 changeCaptcha: true
36 }; 38 };
37 39
  40 + if (testCode === config.testCode) {
  41 + return next();
  42 + }
  43 +
38 // 使用极验证 44 // 使用极验证
39 let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false); 45 let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false);
40 46
@@ -37,6 +37,7 @@ class Validate { @@ -37,6 +37,7 @@ class Validate {
37 }, (captchaObj) => { 37 }, (captchaObj) => {
38 this.captchaObj = captchaObj; 38 this.captchaObj = captchaObj;
39 captchaObj.appendTo($('#js-img-check')); 39 captchaObj.appendTo($('#js-img-check'));
  40 + $('#js-img-check').after('<input id="yohobuy" type="text" style="display:none;">');
40 this._atWorking = true; 41 this._atWorking = true;
41 $('#js-img-check').addClass('hide').addClass('popup'); 42 $('#js-img-check').addClass('hide').addClass('popup');
42 }); 43 });
@@ -72,6 +73,9 @@ class Validate { @@ -72,6 +73,9 @@ class Validate {
72 if (this.type === validType.IMG_CHECK) { 73 if (this.type === validType.IMG_CHECK) {
73 return this.imgCheck.getResults(); 74 return this.imgCheck.getResults();
74 } else { 75 } else {
  76 + if ($('#yohobuy').val()) {
  77 + return '';
  78 + }
75 return new Promise((resolve) => { 79 return new Promise((resolve) => {
76 $('#js-img-check').removeClass('hide'); 80 $('#js-img-check').removeClass('hide');
77 this.captchaObj.onSuccess(() => { 81 this.captchaObj.onSuccess(() => {