...
|
...
|
@@ -11,7 +11,6 @@ const passport = require('passport'); |
|
|
const uuid = require('uuid');
|
|
|
const url = require('url');
|
|
|
const moment = require('moment');
|
|
|
const co = Promise.coroutine;
|
|
|
const cookie = global.yoho.cookie;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const log = global.yoho.logger;
|
...
|
...
|
@@ -547,46 +546,6 @@ exports.user = function(req, res, next) { |
|
|
res.jsonp(result);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 中间件
|
|
|
* 根据用户登录是否成功决定是否展示验证码
|
|
|
*/
|
|
|
exports.loginShowCaptchaByIp = function(req, res, next) {
|
|
|
// 总开关状态
|
|
|
req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
|
|
|
|
|
|
// 开关打开,不走任何验证逻辑
|
|
|
if (!req.yoho.captchaShow) {
|
|
|
return next();
|
|
|
} else {
|
|
|
req.yoho.captchaShow = false;
|
|
|
}
|
|
|
|
|
|
// 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示
|
|
|
let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false);
|
|
|
|
|
|
log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`);
|
|
|
|
|
|
if (firstLoginShowCaptcha) {
|
|
|
req.yoho.captchaShow = true;
|
|
|
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;
|
|
|
exports.local = local;
|
|
|
exports.wechat = wechat;
|
...
|
...
|
|