|
@@ -28,7 +28,7 @@ class LoginController extends WebAction |
|
@@ -28,7 +28,7 @@ class LoginController extends WebAction |
28
|
if (!strstr($refer, 'http')) {
|
28
|
if (!strstr($refer, 'http')) {
|
29
|
$refer = SITE_MAIN . $refer;
|
29
|
$refer = SITE_MAIN . $refer;
|
30
|
}
|
30
|
}
|
31
|
-
|
31
|
+
|
32
|
if (!empty($refer)) {
|
32
|
if (!empty($refer)) {
|
33
|
$this->setCookie('refer', $refer);
|
33
|
$this->setCookie('refer', $refer);
|
34
|
}
|
34
|
}
|
|
@@ -70,7 +70,7 @@ class LoginController extends WebAction |
|
@@ -70,7 +70,7 @@ class LoginController extends WebAction |
70
|
*/
|
70
|
*/
|
71
|
public function authAction()
|
71
|
public function authAction()
|
72
|
{
|
72
|
{
|
73
|
- $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="'.Helpers::url('/passport/back/index').'" target="_blank">忘记密码?</a>', 'data' => '');
|
73
|
+ $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
|
74
|
do {
|
74
|
do {
|
75
|
/* 判断是不是AJAX请求 */
|
75
|
/* 判断是不是AJAX请求 */
|
76
|
if (!$this->isAjax()) {
|
76
|
if (!$this->isAjax()) {
|
|
@@ -108,26 +108,43 @@ class LoginController extends WebAction |
|
@@ -108,26 +108,43 @@ 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);
|
111
|
$accountKey = md5('account_signin_' . $account);
|
112
|
$accountKey = md5('account_signin_' . $account);
|
112
|
- PassportModel::increment($ipKey, 1, 0, 3600);
|
113
|
+ $accountTimeKey = md5('account_signin_time' . $account);
|
|
|
114
|
+ //cache初始化,非有效时间内清除次数,有效时间内叠加cache计数
|
|
|
115
|
+ if (!Cache::get($accountTimeKey) && Cache::get($accountKey)) {
|
|
|
116
|
+ Cache::delete($accountKey);
|
|
|
117
|
+ }
|
|
|
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);
|
|
|
128
|
+ }
|
113
|
$accountTimes = Cache::get($accountKey);
|
129
|
$accountTimes = Cache::get($accountKey);
|
114
|
- if ($accountTimes > 10) {
|
130
|
+ $ipTimes = Cache::get($ipKey);
|
|
|
131
|
+ if ($accountTimes >= 10) {
|
115
|
$data = array('code' => 400, 'message' => '您的账号已被暂时锁定,请稍后再试', 'data' => '');
|
132
|
$data = array('code' => 400, 'message' => '您的账号已被暂时锁定,请稍后再试', 'data' => '');
|
116
|
break;
|
133
|
break;
|
117
|
}
|
134
|
}
|
118
|
-
|
|
|
119
|
- $ipTimes = Cache::get($ipKey);
|
|
|
120
|
- if ($ipTimes > 100) {
|
135
|
+ if ($ipTimes >= 100) {
|
121
|
$data = array('code' => 400, 'message' => '您尝试的次数过多,账号已被暂时锁定,请稍后再试', 'data' => '');
|
136
|
$data = array('code' => 400, 'message' => '您尝试的次数过多,账号已被暂时锁定,请稍后再试', 'data' => '');
|
122
|
break;
|
137
|
break;
|
123
|
}
|
138
|
}
|
124
|
$data = LoginData::signin($area, $account, $password, $shoppingKey);
|
139
|
$data = LoginData::signin($area, $account, $password, $shoppingKey);
|
125
|
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
|
140
|
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
|
126
|
- PassportModel::increment($accountKey, 1, 0, 1800);
|
|
|
127
|
- $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="'.Helpers::url('/passport/back/index').'" target="_blank">忘记密码?</a>', 'data' => '');
|
141
|
+ Cache::set($accountKey, intval(Cache::get($accountKey)) + 1);
|
|
|
142
|
+ Cache::set($ipKey, intval(Cache::get($ipKey)) + 1);
|
|
|
143
|
+ $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
|
128
|
break;
|
144
|
break;
|
129
|
}
|
145
|
}
|
130
|
|
146
|
|
|
|
147
|
+ //登录成功
|
131
|
$refer = $this->getCookie('refer');
|
148
|
$refer = $this->getCookie('refer');
|
132
|
if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) {
|
149
|
if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) {
|
133
|
$refer = SITE_MAIN;
|
150
|
$refer = SITE_MAIN;
|