Authored by 郭成尧

verify-img-timeout

@@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => { @@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => {
38 }, ''); 38 }, '');
39 39
40 req.session.captcha = codeStr; 40 req.session.captcha = codeStr;
  41 + req.session.captchaTimeout = new Date().getTime() + 1000 * 60;
41 req.session.captchaSrc = result.data.verifiedGraphicCode; 42 req.session.captchaSrc = result.data.verifiedGraphicCode;
42 43
43 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 44 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) => { @@ -52,6 +53,17 @@ exports.imgCheck = (req, res, next) => {
52 exports.validate = (req, res, next) => { 53 exports.validate = (req, res, next) => {
53 let captchaInput = req.body.captcha; 54 let captchaInput = req.body.captcha;
54 let captchaCode = _.get(req.session, 'captcha'); 55 let captchaCode = _.get(req.session, 'captcha');
  56 + let captchaTimeout = _.get(req.session, 'captchaTimeout');
  57 +
  58 + if (new Date().getTime() > captchaTimeout) {
  59 + _.set(req.session, 'captchaValidCount', 5);
  60 + req.session.captcha = null;
  61 + return res.json({
  62 + code: 400,
  63 + message: '验证码超时,请重试',
  64 + captchaShow: true
  65 + });
  66 + }
55 67
56 let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次 68 let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次
57 69
@@ -14,8 +14,8 @@ const domains = { @@ -14,8 +14,8 @@ const domains = {
14 liveApi: 'http://testapi.live.yohops.com:9999/', 14 liveApi: 'http://testapi.live.yohops.com:9999/',
15 singleApi: 'http://api-test3.yohops.com:9999/', 15 singleApi: 'http://api-test3.yohops.com:9999/',
16 16
17 - api: 'http://api.yoho.cn/',  
18 - service: 'http://service.yoho.cn/', 17 + api: 'http://api-test3.yohops.com:9999/',
  18 + service: 'http://service-test3.yohops.com:9999/',
19 global: 'http://api-global.yohobuy.com', 19 global: 'http://api-global.yohobuy.com',
20 20
21 // liveApi: 'http://api.live.yoho.cn/', 21 // liveApi: 'http://api.live.yoho.cn/',