...
|
...
|
@@ -67,23 +67,18 @@ passport.use('local', new LocalStrategy({ |
|
|
let shoppingKey = cookie.getShoppingKey(req);
|
|
|
|
|
|
let account = req.body.account;
|
|
|
let ip = req.ip;
|
|
|
|
|
|
let errorLoginKey = 'account_errorlogin_' + account;
|
|
|
let accountKey = 'account_signin_' + account;
|
|
|
let ipKey = 'ip_signin_' + ip;
|
|
|
|
|
|
let cacheGet = [cache.get(errorLoginKey), cache.get(accountKey), cache.get(ipKey)];
|
|
|
let cacheGet = [cache.get(errorLoginKey), cache.get(accountKey)];
|
|
|
|
|
|
Promise.all(cacheGet).then(times => {
|
|
|
let errLoginTimes = _.parseInt(times[0]) || 0;
|
|
|
let accountTimes = _.parseInt(times[1]) || 0;
|
|
|
let ipTimes = _.parseInt(times[2]) || 0;
|
|
|
|
|
|
if (accountTimes >= 10) {
|
|
|
done({message: '您的账号已被暂时锁定,请稍后再试'}, null);
|
|
|
} else if (ipTimes >= 100) {
|
|
|
done({message: '您尝试的次数过多,账号已被暂时锁定,请稍后再试'}, null);
|
|
|
} else {
|
|
|
return AuthHelper.signinAes(area, username, password, shoppingKey).then((result) => {
|
|
|
if (result.code && result.code === 200 && result.data.uid) {
|
...
|
...
|
@@ -93,15 +88,11 @@ passport.use('local', new LocalStrategy({ |
|
|
} else {
|
|
|
errLoginTimes = errLoginTimes + 1;
|
|
|
accountTimes = accountTimes + 1;
|
|
|
ipTimes = ipTimes + 1;
|
|
|
cache.set(errorLoginKey, errLoginTimes);
|
|
|
cache.set(accountKey, accountTimes, 1800);
|
|
|
cache.set(ipKey, ipTimes, 3600);
|
|
|
|
|
|
// 再次校验
|
|
|
if (ipTimes >= 100) {
|
|
|
done({message: '您尝试的次数过多,账号已被暂时锁定,请稍后再试'}, null);
|
|
|
} else if (accountTimes >= 10) {
|
|
|
if (accountTimes >= 10) {
|
|
|
done({message: '您的账号已被暂时锁定,请稍后再试'}, null);
|
|
|
} else if (errLoginTimes >= 3) {
|
|
|
done({
|
...
|
...
|
|