|
@@ -108,24 +108,14 @@ class LoginController extends WebAction |
|
@@ -108,24 +108,14 @@ class LoginController extends WebAction |
108
|
*/
|
108
|
*/
|
109
|
$ip = Helpers::getClientIp();
|
109
|
$ip = Helpers::getClientIp();
|
110
|
$ipKey = md5('ip_signin_' . $ip);
|
110
|
$ipKey = md5('ip_signin_' . $ip);
|
111
|
- $ipTimeKey = md5('ip_signin_time' . $ip);
|
|
|
112
|
$accountKey = md5('account_signin_' . $account);
|
111
|
$accountKey = md5('account_signin_' . $account);
|
113
|
- $accountTimeKey = md5('account_signin_time' . $account);
|
|
|
114
|
- //cache初始化,非有效时间内清除次数,有效时间内叠加cache计数
|
|
|
115
|
- if (!Cache::get($accountTimeKey) && Cache::get($accountKey)) {
|
|
|
116
|
- Cache::delete($accountKey);
|
112
|
+ if (!Cache::get($accountKey)) {
|
|
|
113
|
+ Cache::set($accountKey, 0, 1800);
|
117
|
}
|
114
|
}
|
118
|
- if (!Cache::get($accountTimeKey) && !Cache::get($accountKey)) {
|
|
|
119
|
- Cache::set($accountTimeKey, true, 1800);
|
|
|
120
|
- Cache::set($accountKey, 0);
|
|
|
121
|
- }
|
|
|
122
|
- if (!Cache::get($ipTimeKey) && Cache::get($ipKey)) {
|
|
|
123
|
- Cache::delete($ipKey);
|
|
|
124
|
- }
|
|
|
125
|
- if (!Cache::get($ipTimeKey) && !Cache::get($ipKey)) {
|
|
|
126
|
- Cache::set($ipTimeKey, true, 3600);
|
|
|
127
|
- Cache::set($ipKey, 0);
|
115
|
+ if (!Cache::get($ipKey)) {
|
|
|
116
|
+ Cache::set($ipKey, 0, 3600);
|
128
|
}
|
117
|
}
|
|
|
118
|
+ //调用接口前校验次数
|
129
|
$accountTimes = Cache::get($accountKey);
|
119
|
$accountTimes = Cache::get($accountKey);
|
130
|
$ipTimes = Cache::get($ipKey);
|
120
|
$ipTimes = Cache::get($ipKey);
|
131
|
if ($accountTimes >= 10) {
|
121
|
if ($accountTimes >= 10) {
|
|
@@ -138,8 +128,19 @@ class LoginController extends WebAction |
|
@@ -138,8 +128,19 @@ class LoginController extends WebAction |
138
|
}
|
128
|
}
|
139
|
$data = LoginData::signin($area, $account, $password, $shoppingKey);
|
129
|
$data = LoginData::signin($area, $account, $password, $shoppingKey);
|
140
|
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
|
130
|
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
|
141
|
- Cache::set($accountKey, intval(Cache::get($accountKey)) + 1);
|
|
|
142
|
- Cache::set($ipKey, intval(Cache::get($ipKey)) + 1);
|
131
|
+ Cache::set($accountKey, intval(Cache::get($accountKey)) + 1, 1800);
|
|
|
132
|
+ Cache::set($ipKey, intval(Cache::get($ipKey)) + 1, 3600);
|
|
|
133
|
+ //再次校验
|
|
|
134
|
+ $accountTimes = Cache::get($accountKey);
|
|
|
135
|
+ $ipTimes = Cache::get($ipKey);
|
|
|
136
|
+ if ($accountTimes >= 1) {
|
|
|
137
|
+ $data = array('code' => 400, 'message' => '您的账号已被暂时锁定,请稍后再试', 'data' => '');
|
|
|
138
|
+ break;
|
|
|
139
|
+ }
|
|
|
140
|
+ if ($ipTimes >= 100) {
|
|
|
141
|
+ $data = array('code' => 400, 'message' => '您尝试的次数过多,账号已被暂时锁定,请稍后再试', 'data' => '');
|
|
|
142
|
+ break;
|
|
|
143
|
+ }
|
143
|
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
|
144
|
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
|
144
|
break;
|
145
|
break;
|
145
|
}
|
146
|
}
|