Authored by 郭成尧

Merge branch 'feature/verifyimg' into hotfix/errorlog

... ... @@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => {
}, '');
req.session.captcha = codeStr;
req.session.captchaTimeout = new Date().getTime() + 1000 * 60;
req.session.captchaSrc = result.data.verifiedGraphicCode;
return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res); // eslint-disable-line
... ... @@ -52,6 +53,17 @@ exports.imgCheck = (req, res, next) => {
exports.validate = (req, res, next) => {
let captchaInput = req.body.captcha;
let captchaCode = _.get(req.session, 'captcha');
let captchaTimeout = _.get(req.session, 'captchaTimeout');
if (new Date().getTime() > captchaTimeout) {
_.set(req.session, 'captchaValidCount', 5);
req.session.captcha = null;
return res.json({
code: 400,
message: '验证码超时,请重试',
captchaShow: true
});
}
let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次
... ...
... ... @@ -14,8 +14,8 @@ const domains = {
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
global: 'http://api-global.yohobuy.com',
// liveApi: 'http://api.live.yoho.cn/',
... ...
... ... @@ -6,6 +6,9 @@
let $ = require('yoho-jquery'),
ImgCheck = require('plugin/img-check'),
tip = require('plugin/tip');
let loading = require('plugin/loading');
const validType = {
IMG_CHECK: 1,
GEETEST: 2
... ... @@ -94,7 +97,9 @@ class Validate {
}
return Promise.resolve({captcha});
} else {
loading.showLoadingMask();
return new Promise((resolve) => {
loading.hideLoadingMask();
this.$container.removeClass('hide');
this.captchaObj.onSuccess(() => {
resolve(this.captchaObj.getValidate());
... ...