Authored by 梁志锋

Merge remote-tracking branch 'remotes/origin/hotfix/loginReg'

@@ -67,23 +67,18 @@ passport.use('local', new LocalStrategy({ @@ -67,23 +67,18 @@ passport.use('local', new LocalStrategy({
67 let shoppingKey = cookie.getShoppingKey(req); 67 let shoppingKey = cookie.getShoppingKey(req);
68 68
69 let account = req.body.account; 69 let account = req.body.account;
70 - let ip = req.ip;  
71 70
72 let errorLoginKey = 'account_errorlogin_' + account; 71 let errorLoginKey = 'account_errorlogin_' + account;
73 let accountKey = 'account_signin_' + account; 72 let accountKey = 'account_signin_' + account;
74 - let ipKey = 'ip_signin_' + ip;  
75 73
76 - let cacheGet = [cache.get(errorLoginKey), cache.get(accountKey), cache.get(ipKey)]; 74 + let cacheGet = [cache.get(errorLoginKey), cache.get(accountKey)];
77 75
78 Promise.all(cacheGet).then(times => { 76 Promise.all(cacheGet).then(times => {
79 let errLoginTimes = _.parseInt(times[0]) || 0; 77 let errLoginTimes = _.parseInt(times[0]) || 0;
80 let accountTimes = _.parseInt(times[1]) || 0; 78 let accountTimes = _.parseInt(times[1]) || 0;
81 - let ipTimes = _.parseInt(times[2]) || 0;  
82 79
83 if (accountTimes >= 10) { 80 if (accountTimes >= 10) {
84 done({message: '您的账号已被暂时锁定,请稍后再试'}, null); 81 done({message: '您的账号已被暂时锁定,请稍后再试'}, null);
85 - } else if (ipTimes >= 100) {  
86 - done({message: '您尝试的次数过多,账号已被暂时锁定,请稍后再试'}, null);  
87 } else { 82 } else {
88 return AuthHelper.signinAes(area, username, password, shoppingKey).then((result) => { 83 return AuthHelper.signinAes(area, username, password, shoppingKey).then((result) => {
89 if (result.code && result.code === 200 && result.data.uid) { 84 if (result.code && result.code === 200 && result.data.uid) {
@@ -93,15 +88,11 @@ passport.use('local', new LocalStrategy({ @@ -93,15 +88,11 @@ passport.use('local', new LocalStrategy({
93 } else { 88 } else {
94 errLoginTimes = errLoginTimes + 1; 89 errLoginTimes = errLoginTimes + 1;
95 accountTimes = accountTimes + 1; 90 accountTimes = accountTimes + 1;
96 - ipTimes = ipTimes + 1;  
97 cache.set(errorLoginKey, errLoginTimes); 91 cache.set(errorLoginKey, errLoginTimes);
98 cache.set(accountKey, accountTimes, 1800); 92 cache.set(accountKey, accountTimes, 1800);
99 - cache.set(ipKey, ipTimes, 3600);  
100 93
101 // 再次校验 94 // 再次校验
102 - if (ipTimes >= 100) {  
103 - done({message: '您尝试的次数过多,账号已被暂时锁定,请稍后再试'}, null);  
104 - } else if (accountTimes >= 10) { 95 + if (accountTimes >= 10) {
105 done({message: '您的账号已被暂时锁定,请稍后再试'}, null); 96 done({message: '您的账号已被暂时锁定,请稍后再试'}, null);
106 } else if (errLoginTimes >= 3) { 97 } else if (errLoginTimes >= 3) {
107 done({ 98 done({
@@ -202,7 +202,7 @@ const verifyEmail = email => { @@ -202,7 +202,7 @@ const verifyEmail = email => {
202 return false; 202 return false;
203 } 203 }
204 204
205 - const emailRegExp = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; 205 + const emailRegExp = /^[\.a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
206 206
207 return emailRegExp.test(email); 207 return emailRegExp.test(email);
208 }; 208 };
@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 "uuid": "^2.0.2", 59 "uuid": "^2.0.2",
60 "winston": "^2.2.0", 60 "winston": "^2.2.0",
61 "winston-daily-rotate-file": "^1.1.4", 61 "winston-daily-rotate-file": "^1.1.4",
62 - "yoho-node-lib": "0.0.26" 62 + "yoho-node-lib": "0.0.27"
63 }, 63 },
64 "devDependencies": { 64 "devDependencies": {
65 "autoprefixer": "^6.3.6", 65 "autoprefixer": "^6.3.6",