Showing
2 changed files
with
16 additions
and
7 deletions
@@ -15,7 +15,7 @@ const cookie = global.yoho.cookie; | @@ -15,7 +15,7 @@ const cookie = global.yoho.cookie; | ||
15 | const helpers = global.yoho.helpers; | 15 | const helpers = global.yoho.helpers; |
16 | const log = global.yoho.logger; | 16 | const log = global.yoho.logger; |
17 | const config = global.yoho.config; | 17 | const config = global.yoho.config; |
18 | -const cache = global.yoho.cache.master; | 18 | +const cache = global.yoho.cache; |
19 | const utils = require(global.utils); | 19 | const utils = require(global.utils); |
20 | const RegService = require('../models/reg-service'); | 20 | const RegService = require('../models/reg-service'); |
21 | const AuthHelper = require('../models/auth-helper'); | 21 | const AuthHelper = require('../models/auth-helper'); |
@@ -191,7 +191,7 @@ const local = { | @@ -191,7 +191,7 @@ const local = { | ||
191 | captchaShow: true | 191 | captchaShow: true |
192 | }; | 192 | }; |
193 | 193 | ||
194 | - cache.setAsync(`loginErrorIp:${req.yoho.clientIp}`, true, 3600).catch(log.error); | 194 | + cache.set(`loginErrorIp:${req.yoho.clientIp}`, true, 3600).catch(log.error); |
195 | 195 | ||
196 | res.json(obj); | 196 | res.json(obj); |
197 | } else { | 197 | } else { |
@@ -399,12 +399,14 @@ exports.loginShowCaptchaByIp = function(req, res, next) { | @@ -399,12 +399,14 @@ exports.loginShowCaptchaByIp = function(req, res, next) { | ||
399 | // 开关打开,不走任何验证逻辑 | 399 | // 开关打开,不走任何验证逻辑 |
400 | if (!req.yoho.captchaShow) { | 400 | if (!req.yoho.captchaShow) { |
401 | return next(); | 401 | return next(); |
402 | + } else { | ||
403 | + req.yoho.captchaShow = false; | ||
402 | } | 404 | } |
403 | 405 | ||
404 | co(function*() { | 406 | co(function*() { |
405 | - let hasErrorLog = yield cache.getAsync(`loginErrorIp:${req.yoho.clientIp}`); | 407 | + let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); |
406 | 408 | ||
407 | - log.info(`clientip ${req.yoho.clientIp} status is ` + cache.get(`loginErrorIp:${req.yoho.clientIp}`)); | 409 | + log.info(`clientip ${req.yoho.clientIp} status is ` + hasErrorLog); |
408 | 410 | ||
409 | if (hasErrorLog) { | 411 | if (hasErrorLog) { |
410 | req.yoho.captchaShow = true; | 412 | req.yoho.captchaShow = true; |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | const config = global.yoho.config; | 9 | const config = global.yoho.config; |
10 | const co = Promise.coroutine; | 10 | const co = Promise.coroutine; |
11 | -const cache = global.yoho.cache.master; | 11 | +const cache = global.yoho.cache; |
12 | const geetest = require('./geetest'); | 12 | const geetest = require('./geetest'); |
13 | const captcha = require('./captcha'); | 13 | const captcha = require('./captcha'); |
14 | 14 | ||
@@ -23,16 +23,21 @@ const check = (req, res, next) => { | @@ -23,16 +23,21 @@ const check = (req, res, next) => { | ||
23 | } | 23 | } |
24 | 24 | ||
25 | // 默认取配置总开关来决定是否展示验证码 | 25 | // 默认取配置总开关来决定是否展示验证码 |
26 | - req.yoho.captchaShow = _.get(req.app.locals.wap, 'close.loginValidation', false); | 26 | + req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false); |
27 | 27 | ||
28 | co(function* () { | 28 | co(function* () { |
29 | 29 | ||
30 | + console.log('path:', req.path); | ||
31 | + | ||
30 | // 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码 | 32 | // 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码 |
31 | if (req.path === '/passport/login/auth') { | 33 | if (req.path === '/passport/login/auth') { |
32 | - let hasErrorLog = yield cache.getAsync(`loginErrorIp:${req.yoho.clientIp}`); | 34 | + let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`); |
33 | 35 | ||
36 | + console.log('hasErrorLog:', req.yoho.captchaShow); | ||
34 | if (hasErrorLog) { | 37 | if (hasErrorLog) { |
35 | req.yoho.captchaShow = true; | 38 | req.yoho.captchaShow = true; |
39 | + } else { | ||
40 | + req.yoho.captchaShow = false; | ||
36 | } | 41 | } |
37 | } | 42 | } |
38 | 43 | ||
@@ -47,6 +52,8 @@ const check = (req, res, next) => { | @@ -47,6 +52,8 @@ const check = (req, res, next) => { | ||
47 | return next(); | 52 | return next(); |
48 | } | 53 | } |
49 | 54 | ||
55 | + console.log('开始校验验证码'); | ||
56 | + | ||
50 | // 使用极验证 | 57 | // 使用极验证 |
51 | let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false); | 58 | let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false); |
52 | 59 |
-
Please register or login to post a comment