From 8dcfae4fff98fbbb19ff46bd9750f25bc56801a9 Mon Sep 17 00:00:00 2001 From: zhaojs <349234519@qq.com> Date: 星期一, 31 七月 2023 10:42:20 +0800 Subject: [PATCH] Merge branch 'release/v1.1.5发布' --- application/common/library/Auth.php | 68 ++++++++++++++++++++++++++++++++- 1 files changed, 65 insertions(+), 3 deletions(-) diff --git a/application/common/library/Auth.php b/application/common/library/Auth.php index 21e4b88..1c023ee 100644 --- a/application/common/library/Auth.php +++ b/application/common/library/Auth.php @@ -12,6 +12,7 @@ use think\Request; use think\Validate; use app\common\model\user\Third as ModelThird; +use EasyWeChat\Kernel\Support\AES; class Auth { @@ -122,6 +123,62 @@ } } + public function initSession($sessionkey,$params) + { + //$sessionkey鍒嗕袱閮ㄥ垎锛�.鍓嶆槸md5鍔犲瘑锛�.鍚庢槸aes鍔犲瘑鐨剈serid + //鏍¢獙sessionkey鏄惁鍚堟硶 + $enstrs=""; + $searr=explode('.',$sessionkey); + if(count($searr)!=2) + { + $this->setError('Account not exist'); + return false; + } + foreach ($params as $key => $value) { + $enstrs=$enstrs.$key; + $pvalue=preg_replace('/^\"|\"$/','',json_encode($value,JSON_UNESCAPED_UNICODE)); + $enstrs=$enstrs.$pvalue; + } + $enstrs="dfg".$enstrs."apph5".$searr[1]; + $enstrs=md5($enstrs,false); + if($enstrs!=$searr[0]) + {//session鏍¢獙涓嶉�氳繃 + $this->setError('Account not exist'); + return false; + } + //aes瑙e瘑 + $enKey="wp4hs3bvu7wq2mud"; + $iv = 'fedcba9876543210'; + $user_id = AES::decrypt(base64_decode($searr[1],true),$enKey, $iv); + if(empty($user_id)) + { + $this->setError('Account not exist'); + return false; + } + if ($user_id > 0) { + $user = User::get($user_id); + if (!$user) { + $this->setError('Account not exist'); + return false; + } + if ($user['status'] != 'normal') { + $this->setError('Account is locked'); + return false; + } + $this->_user = $user; + $this->_logined = true; + $this->_token = $user_id; + + //鍒濆鍖栨垚鍔熺殑浜嬩欢 + Hook::listen("user_init_successed", $this->_user); + + return true; + } else { + $this->setError('You are not logged in'); + return false; + } + } + /** * 娉ㄥ唽鐢ㄦ埛 * @@ -134,7 +191,7 @@ * @param string $third_info 涓夋柟鐢ㄦ埛淇℃伅 娉�:闇�淇濇寔缁熶竴缁撴瀯 * @return boolean */ - public function register($username = '', $password, $email = '', $mobile = '', $extend = [],$third_platform="",$third_info=[]) + public function register($username = '', $password, $email = '', $mobile = '', $extend = [],$third_platform="",$third_info=[],$pushCid="") { // 妫�娴嬬敤鎴峰悕銆佹樀绉般�侀偖绠便�佹墜鏈哄彿鏄惁瀛樺湪 if(!empty($third_platform) && !empty($third_info)){ @@ -184,7 +241,8 @@ 'logintime' => $time, 'loginip' => $ip, 'prevtime' => $time, - 'status' => 'normal' + 'status' => 'normal', + 'push_cid'=>$pushCid ]); //$params['password'] = $this->getEncryptPassword($password, $params['salt']); $params = array_merge($params, $extend); @@ -340,7 +398,7 @@ * @param int $user_id * @return boolean */ - public function direct($user_id) + public function direct($user_id,$pushCid='') { $user = User::get($user_id); if ($user) { @@ -363,6 +421,10 @@ //!empty(PUSH_CID) && $user->push_cid = PUSH_CID; //閲嶇疆鐧诲綍澶辫触娆℃暟 $user->loginfailure = 0; + if(!empty($pushCid)) + { + $user->push_cid=$pushCid; + } $user->save(); $this->_user = $user; $this->_token = Random::uuid(); -- Gitblit v1.9.3