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 | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/application/common/library/Auth.php b/application/common/library/Auth.php index 6de3231..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; + } + } + /** * 娉ㄥ唽鐢ㄦ埛 * -- Gitblit v1.9.3