|
@@ -11,7 +11,6 @@ const passport = require('passport'); |
|
@@ -11,7 +11,6 @@ const passport = require('passport'); |
11
|
const uuid = require('uuid');
|
11
|
const uuid = require('uuid');
|
12
|
const url = require('url');
|
12
|
const url = require('url');
|
13
|
const moment = require('moment');
|
13
|
const moment = require('moment');
|
14
|
-const co = Promise.coroutine;
|
|
|
15
|
const cookie = global.yoho.cookie;
|
14
|
const cookie = global.yoho.cookie;
|
16
|
const helpers = global.yoho.helpers;
|
15
|
const helpers = global.yoho.helpers;
|
17
|
const log = global.yoho.logger;
|
16
|
const log = global.yoho.logger;
|
|
@@ -547,46 +546,6 @@ exports.user = function(req, res, next) { |
|
@@ -547,46 +546,6 @@ exports.user = function(req, res, next) { |
547
|
res.jsonp(result);
|
546
|
res.jsonp(result);
|
548
|
};
|
547
|
};
|
549
|
|
548
|
|
550
|
-/**
|
|
|
551
|
- * 中间件
|
|
|
552
|
- * 根据用户登录是否成功决定是否展示验证码
|
|
|
553
|
- */
|
|
|
554
|
-exports.loginShowCaptchaByIp = function(req, res, next) {
|
|
|
555
|
- // 总开关状态
|
|
|
556
|
- req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
|
|
|
557
|
-
|
|
|
558
|
- // 开关打开,不走任何验证逻辑
|
|
|
559
|
- if (!req.yoho.captchaShow) {
|
|
|
560
|
- return next();
|
|
|
561
|
- } else {
|
|
|
562
|
- req.yoho.captchaShow = false;
|
|
|
563
|
- }
|
|
|
564
|
-
|
|
|
565
|
- // 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示
|
|
|
566
|
- let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false);
|
|
|
567
|
-
|
|
|
568
|
- log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`);
|
|
|
569
|
-
|
|
|
570
|
- if (firstLoginShowCaptcha) {
|
|
|
571
|
- req.yoho.captchaShow = true;
|
|
|
572
|
- return next();
|
|
|
573
|
- } else {
|
|
|
574
|
- co(function* () {
|
|
|
575
|
- let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
|
|
|
576
|
-
|
|
|
577
|
- log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog);
|
|
|
578
|
-
|
|
|
579
|
- if (hasErrorLog) {
|
|
|
580
|
- req.yoho.captchaShow = true;
|
|
|
581
|
- }
|
|
|
582
|
- next();
|
|
|
583
|
- })().catch(function(e) {
|
|
|
584
|
- req.yoho.captchaShow = true;
|
|
|
585
|
- next();
|
|
|
586
|
- });
|
|
|
587
|
- }
|
|
|
588
|
-};
|
|
|
589
|
-
|
|
|
590
|
exports.common = common;
|
549
|
exports.common = common;
|
591
|
exports.local = local;
|
550
|
exports.local = local;
|
592
|
exports.wechat = wechat;
|
551
|
exports.wechat = wechat;
|