修复 #41

Merged
yunyang merged 1 commits from yy-4.20 into master 2 years ago

@ -12,6 +12,7 @@ use think\Request;
use think\Db;
use app\common\adapter\AuthAdapter;
use app\common\controller\Common;
use think\Session;
class ApiCommon extends Common
@ -25,7 +26,7 @@ class ApiCommon extends Common
$authKey = trim($header['authkey']);
$sessionId = trim($header['sessionid']);
if ($authKey == "wxwork") {
if ($authKey == "wxwork" && Session::get('user_id')) {
return;
}
$paramArr = $request->param();

@ -13,6 +13,7 @@ use app\admin\model\Common;
use com\verify\HonrayVerify;
use think\Cache;
use think\Request;
use think\Session;
class User extends Common
{
@ -647,8 +648,15 @@ class User extends Common
$data['loginExpire'] = $loginExpire;
//保存authKey信息
$userData = [];
$userData['authkey'] = $authKey;
$userData['authkey_time'] = time() + $loginExpire;
$wxuser_id = Session::get('wxuser_id');
if ($wxuser_id) {
$data['authKey'] = 'wxwork';
$userData['wxwork_id'] = $wxuser_id;
} else {
$userData['authkey'] = $authKey;
$userData['authkey_time'] = time() + $loginExpire;
}
//把状态未激活至为启用
if ($userInfo['status'] == 2) {
$userData['status'] = 1;

@ -9,6 +9,7 @@ namespace app\common\behavior;
use think\Cache;
use think\Request;
use think\Db;
use think\Session;
class AuthenticateBehavior
{
@ -32,7 +33,7 @@ class AuthenticateBehavior
/*获取头部信息*/
$header = $request->header();
$authKey = trim($header['authkey']);
if ($authKey == "wxwork") {
if ($authKey == "wxwork" && Session::get('user_id')) {
return true;
}

@ -126,7 +126,14 @@ class Callback extends Controller
$code = Request::instance()->get('code');
$api = new Api(config('wework.corpId'), config('wework.corpSecret'));
$userInfo = $api->getUserInfo($code);
Session::set('user_id', $userInfo['userid']);
return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid=wxwork');
if ($userInfo) {
Session::set('wxuser_id', $userInfo['userid']);
$adminUser = db('admin_user')->where('wxwork_id', $userInfo['userid'])->find();
if ($adminUser) {
Session::set('user_id', $adminUser['id']);
return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id());
}
}
return redirect('http://web.lbschem.com:8088/');
}
}
Loading…
Cancel
Save