Showing
5 changed files
with
21 additions
and
4 deletions
@@ -3,12 +3,12 @@ | @@ -3,12 +3,12 @@ | ||
3 | */ | 3 | */ |
4 | 4 | ||
5 | 'use strict'; | 5 | 'use strict'; |
6 | -const _ =require('lodash'); | 6 | +const _ = require('lodash'); |
7 | 7 | ||
8 | const captchaService = require('../models/captcha-img-service'); | 8 | const captchaService = require('../models/captcha-img-service'); |
9 | const gtestCaptcha = require('./gee-captcha'); | 9 | const gtestCaptcha = require('./gee-captcha'); |
10 | const helpers = global.yoho.helpers; | 10 | const helpers = global.yoho.helpers; |
11 | -const CAPTCHA = 'yoho4946abcdef#$%&!@'; | 11 | +const CAPTCHA = global.yoho.config.UNIVERSAL_CAPTCHA; |
12 | const request = require('request'); | 12 | const request = require('request'); |
13 | const logger = global.yoho.logger; | 13 | const logger = global.yoho.logger; |
14 | 14 |
@@ -9,6 +9,7 @@ const Geetest = require('../models/captcha-gee-service'); | @@ -9,6 +9,7 @@ const Geetest = require('../models/captcha-gee-service'); | ||
9 | 9 | ||
10 | const config = global.yoho.config; | 10 | const config = global.yoho.config; |
11 | const logger = global.yoho.logger; | 11 | const logger = global.yoho.logger; |
12 | +const CAPTCHA = config.UNIVERSAL_CAPTCHA; | ||
12 | 13 | ||
13 | var pcGeetest = new Geetest({ | 14 | var pcGeetest = new Geetest({ |
14 | geetest_id: config.gee_captcha.id, | 15 | geetest_id: config.gee_captcha.id, |
@@ -44,6 +45,10 @@ const requiredAPI = (req, res, next) => { | @@ -44,6 +45,10 @@ const requiredAPI = (req, res, next) => { | ||
44 | }); | 45 | }); |
45 | } | 46 | } |
46 | 47 | ||
48 | + if (verifyCode === CAPTCHA) { | ||
49 | + return next(); | ||
50 | + } | ||
51 | + | ||
47 | pcGeetest.validate({ | 52 | pcGeetest.validate({ |
48 | challenge: captcha[0], | 53 | challenge: captcha[0], |
49 | validate: captcha[1], | 54 | validate: captcha[1], |
@@ -118,6 +118,7 @@ module.exports = { | @@ -118,6 +118,7 @@ module.exports = { | ||
118 | id: '356b333091cdb78cd788e7bdd5f05c9f', | 118 | id: '356b333091cdb78cd788e7bdd5f05c9f', |
119 | key: '6fef8ee77e41429de68455eeb052ce37' | 119 | key: '6fef8ee77e41429de68455eeb052ce37' |
120 | }, | 120 | }, |
121 | + UNIVERSAL_CAPTCHA: 'yoho4946abcdef#$%&!@', | ||
121 | apiCache: { | 122 | apiCache: { |
122 | cache: false | 123 | cache: false |
123 | }, | 124 | }, |
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | 4 | ||
5 | var $ = require('yoho-jquery'); | 5 | var $ = require('yoho-jquery'); |
6 | 6 | ||
7 | -require('../common/promise'); | ||
8 | 7 | ||
9 | var GeeCaptcha = function(container, options) { | 8 | var GeeCaptcha = function(container, options) { |
10 | var optionDefault = { | 9 | var optionDefault = { |
@@ -18,6 +17,10 @@ var GeeCaptcha = function(container, options) { | @@ -18,6 +17,10 @@ var GeeCaptcha = function(container, options) { | ||
18 | this.$tip = this.$container.find('.img-check-tip-gee'); | 17 | this.$tip = this.$container.find('.img-check-tip-gee'); |
19 | this._result = []; | 18 | this._result = []; |
20 | this._captchObj = null; | 19 | this._captchObj = null; |
20 | + | ||
21 | + // NODE: 这个是专门给自动化测试做的后门 | ||
22 | + this.$_____trojanYohobuy = this.$container.find('#yohobuy'); | ||
23 | + | ||
21 | return this; | 24 | return this; |
22 | }; | 25 | }; |
23 | 26 | ||
@@ -26,7 +29,7 @@ GeeCaptcha.prototype = { | @@ -26,7 +29,7 @@ GeeCaptcha.prototype = { | ||
26 | var _this = this; | 29 | var _this = this; |
27 | 30 | ||
28 | $.get('/passport/geetest/register?t=' + $.now()).then(function(data) { | 31 | $.get('/passport/geetest/register?t=' + $.now()).then(function(data) { |
29 | - initGeetest && initGeetest({ | 32 | + initGeetest && initGeetest({ // eslint-disable-line |
30 | gt: data.gt, | 33 | gt: data.gt, |
31 | challenge: data.challenge, | 34 | challenge: data.challenge, |
32 | product: 'float', // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效 | 35 | product: 'float', // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效 |
@@ -107,6 +110,11 @@ GeeCaptcha.prototype = { | @@ -107,6 +110,11 @@ GeeCaptcha.prototype = { | ||
107 | }, | 110 | }, |
108 | 111 | ||
109 | getResults: function() { | 112 | getResults: function() { |
113 | + if (this.$_____trojanYohobuy && this.$_____trojanYohobuy.val()) { | ||
114 | + this._result = []; | ||
115 | + this._result.push(this.$_____trojanYohobuy.val()); | ||
116 | + } | ||
117 | + | ||
110 | return this._result.join(','); | 118 | return this._result.join(','); |
111 | }, | 119 | }, |
112 | 120 | ||
@@ -141,5 +149,6 @@ GeeCaptcha.prototype = { | @@ -141,5 +149,6 @@ GeeCaptcha.prototype = { | ||
141 | 149 | ||
142 | GeeCaptcha.prototype.construct = GeeCaptcha; | 150 | GeeCaptcha.prototype.construct = GeeCaptcha; |
143 | 151 | ||
152 | +require('../common/promise'); | ||
144 | 153 | ||
145 | module.exports = GeeCaptcha; | 154 | module.exports = GeeCaptcha; |
-
Please register or login to post a comment