Commit 6eb88cf3 authored by jianghaiming's avatar jianghaiming

update:添加频率锁

parent 55be1fd3
...@@ -33,6 +33,19 @@ class UserService ...@@ -33,6 +33,19 @@ class UserService
throw new UserException(['cus' => 0]); throw new UserException(['cus' => 0]);
} }
$redis = RedisUtil::getInstance('cache');
$key = "wx_wechat_login_".$code;
$keyCode = "wx_wechat_login_code_".$code;
$lock = FrequencyLockUtil::isLocked($key);
if ($lock) {
sleep(1);
$user = $redis->get($keyCode);
if (!empty($user)) {
$user = json_decode($user,true);
}
return $user;
}
//需要授权微信 //需要授权微信
//if (empty($openid)) { //if (empty($openid)) {
$appid = \Yaf\Registry::get('config')->wechat->appid; $appid = \Yaf\Registry::get('config')->wechat->appid;
...@@ -101,7 +114,9 @@ class UserService ...@@ -101,7 +114,9 @@ class UserService
$newWechatId = UserWechatBind::save($insert,['openid' => $openid]); $newWechatId = UserWechatBind::save($insert,['openid' => $openid]);
} }
$user['third_session'] = self::generate3rdSession($openid); $user['third_session'] = self::generate3rdSession($openid);
$redis->set($keyCode, json_encode($user),10);
return $user; return $user;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment