|
@@ -53,46 +53,45 @@ passport.use('local', new LocalStrategy({ |
|
@@ -53,46 +53,45 @@ passport.use('local', new LocalStrategy({ |
53
|
|
53
|
|
54
|
let clientIp = req.yoho.clientIp;
|
54
|
let clientIp = req.yoho.clientIp;
|
55
|
let errorLoginKey = 'loginErrorIp:' + clientIp;
|
55
|
let errorLoginKey = 'loginErrorIp:' + clientIp;
|
56
|
- let closePasswordLogin = _.get(req.app.locals.pc, 'login.closePasswordLogin', false);
|
56
|
+ let close = _.get(req.app.locals.pc, 'login.closePasswordLogin', false);
|
57
|
|
57
|
|
58
|
getLoginStat(clientIp).then((times) => {
|
58
|
getLoginStat(clientIp).then((times) => {
|
59
|
let errLoginTimes = _.parseInt(times) || 0;
|
59
|
let errLoginTimes = _.parseInt(times) || 0;
|
60
|
|
60
|
|
61
|
- return LoginApi.signin(type, area, username, password, shoppingKey, clientIp, closePasswordLogin).
|
|
|
62
|
- then((result) => {
|
|
|
63
|
- if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) {
|
|
|
64
|
- cache.del(errorLoginKey).catch(() => {});
|
|
|
65
|
- req.session.type = '';
|
61
|
+ return LoginApi.signin(type, area, username, password, shoppingKey, clientIp, close).then((result) => {
|
|
|
62
|
+ if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) {
|
|
|
63
|
+ cache.del(errorLoginKey).catch(() => {});
|
|
|
64
|
+ req.session.type = '';
|
|
|
65
|
+
|
|
|
66
|
+ done(null, Object.assign(result.data, {code: result.code}));
|
|
|
67
|
+ } else {
|
|
|
68
|
+ errLoginTimes = errLoginTimes + 1;
|
|
|
69
|
+ cache.set(errorLoginKey, errLoginTimes, 3600).catch(() => {});
|
|
|
70
|
+
|
|
|
71
|
+ if (result.code === 4189) {
|
|
|
72
|
+ return done({
|
|
|
73
|
+ message: `您的密码登录错误次数过多,建议使用手机号码快捷登录或
|
|
|
74
|
+ <a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">找回登陆密码</a>!`
|
|
|
75
|
+ });
|
|
|
76
|
+ }
|
66
|
|
77
|
|
67
|
- done(null, Object.assign(result.data, {code: result.code}));
|
78
|
+ // 再次校验
|
|
|
79
|
+ if (errLoginTimes >= 1) {
|
|
|
80
|
+ req.session.type = 'needCaptcha';
|
|
|
81
|
+ done({
|
|
|
82
|
+ message: `您输入的密码及账户名不匹配,
|
|
|
83
|
+ 是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
|
|
|
84
|
+ needCaptcha: true,
|
|
|
85
|
+ type: type
|
|
|
86
|
+ });
|
68
|
} else {
|
87
|
} else {
|
69
|
- errLoginTimes = errLoginTimes + 1;
|
|
|
70
|
- cache.set(errorLoginKey, errLoginTimes, 3600).catch(() => {});
|
|
|
71
|
-
|
|
|
72
|
- if (result.code === 4189) {
|
|
|
73
|
- return done({
|
|
|
74
|
- message: `您的密码登录错误次数过多,建议使用手机号码快捷登录或
|
|
|
75
|
- <a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">找回登陆密码</a>!`
|
|
|
76
|
- });
|
|
|
77
|
- }
|
|
|
78
|
-
|
|
|
79
|
- // 再次校验
|
|
|
80
|
- if (errLoginTimes >= 1) {
|
|
|
81
|
- req.session.type = 'needCaptcha';
|
|
|
82
|
- done({
|
|
|
83
|
- message: `您输入的密码及账户名不匹配,
|
|
|
84
|
- 是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
|
|
|
85
|
- needCaptcha: true,
|
|
|
86
|
- type: type
|
|
|
87
|
- });
|
|
|
88
|
- } else {
|
|
|
89
|
- done({
|
|
|
90
|
- message: `您输入的密码及账户名不匹配,
|
|
|
91
|
- 是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
|
|
|
92
|
- needCaptcha: false
|
|
|
93
|
- });
|
|
|
94
|
- }
|
88
|
+ done({
|
|
|
89
|
+ message: `您输入的密码及账户名不匹配,
|
|
|
90
|
+ 是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
|
|
|
91
|
+ needCaptcha: false
|
|
|
92
|
+ });
|
95
|
}
|
93
|
}
|
|
|
94
|
+ }
|
96
|
});
|
95
|
});
|
97
|
}).catch(e => {
|
96
|
}).catch(e => {
|
98
|
logger.error('call the signin service fail,', e);
|
97
|
logger.error('call the signin service fail,', e);
|