|
@@ -42,7 +42,7 @@ class WechatOpenPlatformController extends CatchController
|
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByCompanyUid($currentUser->id);
|
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
|
$user_id = $request->input('user_id');
|
|
|
- $url = $app->createPreAuthorizationUrl(sprintf('%s/api/channel/openPlatform/auth/%s/%s',config('app.url'), $componentInfo->app_id, $user_id), []);
|
|
|
+ $url = $app->getPreAuthorizationUrl(sprintf('%s/api/channel/openPlatform/auth/%s/%s',config('app.url'), $componentInfo->app_id, $user_id), []);
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
@@ -71,29 +71,26 @@ class WechatOpenPlatformController extends CatchController
|
|
|
}
|
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
|
- $client = $app->getClient();
|
|
|
- $response = $client->postJson('/cgi-bin/component/api_query_auth', [
|
|
|
- 'component_appid' => $component_appid,
|
|
|
- 'authorization_code' => $auth_code
|
|
|
- ]);
|
|
|
- $parsedContent = \json_decode($response->getContent(), true);
|
|
|
- $authorizer_appid = $parsedContent['authorization_info']['authorizer_appid'];
|
|
|
- $authorizer_refresh_token = $parsedContent['authorization_info']['authorizer_refresh_token'];
|
|
|
+ $authorize = $app->handleAuthorize($auth_code);
|
|
|
+ $authorizer_appid = $authorize['authorization_info']['authorizer_appid'];
|
|
|
+ $authorizer_refresh_token = $authorize['authorization_info']['authorizer_refresh_token'];
|
|
|
+ $gzhBaseInfo = $app->getAuthorizer($authorizer_appid);
|
|
|
|
|
|
- $response = $client->postJson('/cgi-bin/component/api_get_authorizer_info', [
|
|
|
+ WechatAuthorizationInfo::where([
|
|
|
+ 'authorizer_appid' => $authorizer_appid,
|
|
|
'component_appid' => $component_appid,
|
|
|
- 'authorizer_appid' => $authorizer_appid
|
|
|
+ 'puser_id' => $auth_user->pid,
|
|
|
+ 'is_enabled' => 1,
|
|
|
+ ])->update([
|
|
|
+ 'is_enabled' => 0,
|
|
|
]);
|
|
|
- $parsedContent = \json_decode($response->getContent(), true);
|
|
|
-
|
|
|
- WechatAuthorizationInfo::updateOrCreate([
|
|
|
+ WechatAuthorizationInfo::create([
|
|
|
'authorizer_appid' => $authorizer_appid,
|
|
|
'component_appid' => $component_appid,
|
|
|
'user_id' => $user_id,
|
|
|
'puser_id' => $auth_user->pid,
|
|
|
- ], [
|
|
|
'authorizer_refresh_token' => $authorizer_refresh_token,
|
|
|
- 'nick_name' => $parsedContent['authorizer_info']['nick_name'],
|
|
|
+ 'nick_name' => $gzhBaseInfo['authorizer_info']['nick_name'],
|
|
|
]);
|
|
|
|
|
|
return view('wechat.openPlatform.authSuccess')->with('url', sprintf('%s/#/user/advertiser',config('app.url')));
|
|
@@ -108,12 +105,8 @@ class WechatOpenPlatformController extends CatchController
|
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
|
|
|
|
- $server = $app->getServer();
|
|
|
+ $server = $app->server;
|
|
|
|
|
|
- $server->handleAuthorized(function($message, \Closure $next) {
|
|
|
- myLog('authorCommand')->info('handleAuthorized', ['message' => $message]);
|
|
|
- return $next($message);
|
|
|
- });
|
|
|
$server->handleUnauthorized(function($message, \Closure $next) {
|
|
|
WechatOpenPlatformService::handleUnauthorized($message);
|
|
|
return $next($message);
|