Authored by htoooth

fix captcha

... ... @@ -3,12 +3,12 @@
*/
'use strict';
const _ =require('lodash');
const _ = require('lodash');
const captchaService = require('../models/captcha-img-service');
const gtestCaptcha = require('./gee-captcha');
const helpers = global.yoho.helpers;
const CAPTCHA = 'yoho4946abcdef#$%&!@';
const CAPTCHA = global.yoho.config.UNIVERSAL_CAPTCHA;
const request = require('request');
const logger = global.yoho.logger;
... ...
... ... @@ -9,6 +9,7 @@ const Geetest = require('../models/captcha-gee-service');
const config = global.yoho.config;
const logger = global.yoho.logger;
const CAPTCHA = config.UNIVERSAL_CAPTCHA;
var pcGeetest = new Geetest({
geetest_id: config.gee_captcha.id,
... ... @@ -44,6 +45,10 @@ const requiredAPI = (req, res, next) => {
});
}
if (verifyCode === CAPTCHA) {
return next();
}
pcGeetest.validate({
challenge: captcha[0],
validate: captcha[1],
... ...
... ... @@ -118,6 +118,7 @@ module.exports = {
id: '356b333091cdb78cd788e7bdd5f05c9f',
key: '6fef8ee77e41429de68455eeb052ce37'
},
UNIVERSAL_CAPTCHA: 'yoho4946abcdef#$%&!@',
apiCache: {
cache: false
},
... ...
... ... @@ -6,4 +6,6 @@
<i class="iconfont">&#xe61f;</i>
<em>请将图形验证码输入正确</em>
</span>
<input id="yohobuy" type="text" class="hide">
</div>
... ...
... ... @@ -4,7 +4,6 @@
var $ = require('yoho-jquery');
require('../common/promise');
var GeeCaptcha = function(container, options) {
var optionDefault = {
... ... @@ -18,6 +17,10 @@ var GeeCaptcha = function(container, options) {
this.$tip = this.$container.find('.img-check-tip-gee');
this._result = [];
this._captchObj = null;
// NODE: 这个是专门给自动化测试做的后门
this.$_____trojanYohobuy = this.$container.find('#yohobuy');
return this;
};
... ... @@ -26,7 +29,7 @@ GeeCaptcha.prototype = {
var _this = this;
$.get('/passport/geetest/register?t=' + $.now()).then(function(data) {
initGeetest && initGeetest({
initGeetest && initGeetest({ // eslint-disable-line
gt: data.gt,
challenge: data.challenge,
product: 'float', // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
... ... @@ -107,6 +110,11 @@ GeeCaptcha.prototype = {
},
getResults: function() {
if (this.$_____trojanYohobuy && this.$_____trojanYohobuy.val()) {
this._result = [];
this._result.push(this.$_____trojanYohobuy.val());
}
return this._result.join(',');
},
... ... @@ -141,5 +149,6 @@ GeeCaptcha.prototype = {
GeeCaptcha.prototype.construct = GeeCaptcha;
require('../common/promise');
module.exports = GeeCaptcha;
... ...