...
|
...
|
@@ -8,7 +8,7 @@ |
|
|
const _ = require('lodash');
|
|
|
const config = global.yoho.config;
|
|
|
const co = Promise.coroutine;
|
|
|
const cache = global.yoho.cache.master;
|
|
|
const cache = global.yoho.cache;
|
|
|
const geetest = require('./geetest');
|
|
|
const captcha = require('./captcha');
|
|
|
|
...
|
...
|
@@ -23,16 +23,21 @@ const check = (req, res, next) => { |
|
|
}
|
|
|
|
|
|
// 默认取配置总开关来决定是否展示验证码
|
|
|
req.yoho.captchaShow = _.get(req.app.locals.wap, 'close.loginValidation', false);
|
|
|
req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
|
|
|
|
|
|
co(function* () {
|
|
|
|
|
|
console.log('path:', req.path);
|
|
|
|
|
|
// 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码
|
|
|
if (req.path === '/passport/login/auth') {
|
|
|
let hasErrorLog = yield cache.getAsync(`loginErrorIp:${req.yoho.clientIp}`);
|
|
|
let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
|
|
|
|
|
|
console.log('hasErrorLog:', req.yoho.captchaShow);
|
|
|
if (hasErrorLog) {
|
|
|
req.yoho.captchaShow = true;
|
|
|
} else {
|
|
|
req.yoho.captchaShow = false;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -47,6 +52,8 @@ const check = (req, res, next) => { |
|
|
return next();
|
|
|
}
|
|
|
|
|
|
console.log('开始校验验证码');
|
|
|
|
|
|
// 使用极验证
|
|
|
let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false);
|
|
|
|
...
|
...
|
|