...
|
...
|
@@ -266,7 +266,7 @@ const local = { |
|
|
captchaShow: true
|
|
|
};
|
|
|
|
|
|
cache.set(`loginErrorIp:${req.yoho.clientIp}`, true, 3600).catch(log.error);
|
|
|
cache.set(`loginErrorIp:${req.yoho.clientIp}`, true, 3600 * 24).catch(log.error);
|
|
|
return res.json(obj);
|
|
|
}
|
|
|
} else {
|
...
|
...
|
@@ -491,19 +491,29 @@ exports.loginShowCaptchaByIp = function(req, res, next) { |
|
|
req.yoho.captchaShow = false;
|
|
|
}
|
|
|
|
|
|
co(function*() {
|
|
|
let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
|
|
|
// 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示
|
|
|
let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false);
|
|
|
|
|
|
log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog);
|
|
|
log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`);
|
|
|
|
|
|
if (hasErrorLog) {
|
|
|
req.yoho.captchaShow = true;
|
|
|
}
|
|
|
next();
|
|
|
})().catch(function(e) {
|
|
|
if (firstLoginShowCaptcha) {
|
|
|
req.yoho.captchaShow = true;
|
|
|
next();
|
|
|
});
|
|
|
return next();
|
|
|
} else {
|
|
|
co(function* () {
|
|
|
let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
|
|
|
|
|
|
log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog);
|
|
|
|
|
|
if (hasErrorLog) {
|
|
|
req.yoho.captchaShow = true;
|
|
|
}
|
|
|
next();
|
|
|
})().catch(function(e) {
|
|
|
req.yoho.captchaShow = true;
|
|
|
next();
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
exports.common = common;
|
...
|
...
|
|