|
@@ -35,6 +35,15 @@ class WechatOpenPlatformController extends CatchController
|
|
|
|
|
|
public function auth(Request $request, $component_appid, $user_id) {
|
|
public function auth(Request $request, $component_appid, $user_id) {
|
|
$auth_code = $request->input('auth_code');
|
|
$auth_code = $request->input('auth_code');
|
|
|
|
+ $auth_user = DB::table('users')
|
|
|
|
+ ->where([
|
|
|
|
+ 'id' => $user_id, 'deleted_at' => 0, 'status' => 1
|
|
|
|
+ ])
|
|
|
|
+ ->where('pid', '<>', 0)
|
|
|
|
+ ->select('pid', 'id')->first();
|
|
|
|
+ if(!$auth_user) {
|
|
|
|
+ CommonBusinessException::throwError(Errors::OPENPLATFORM_OPTIMIZER_INFO_ERROR);
|
|
|
|
+ }
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
$client = $app->getClient();
|
|
$client = $app->getClient();
|
|
@@ -44,12 +53,12 @@ class WechatOpenPlatformController extends CatchController
|
|
]);
|
|
]);
|
|
$authorizer_appid = $response['authorization_info']['authorizer_appid'];
|
|
$authorizer_appid = $response['authorization_info']['authorizer_appid'];
|
|
$authorizer_refresh_token = $response['authorization_info']['authorizer_refresh_token'];
|
|
$authorizer_refresh_token = $response['authorization_info']['authorizer_refresh_token'];
|
|
- $currentUser = $this->getCurrentUser();
|
|
|
|
|
|
+
|
|
WechatAuthorizationInfo::updateOrCreate([
|
|
WechatAuthorizationInfo::updateOrCreate([
|
|
'authorizer_appid' => $authorizer_appid,
|
|
'authorizer_appid' => $authorizer_appid,
|
|
'component_appid' => $component_appid,
|
|
'component_appid' => $component_appid,
|
|
'user_id' => $user_id,
|
|
'user_id' => $user_id,
|
|
- 'puser_id' => $currentUser->id,
|
|
|
|
|
|
+ 'puser_id' => $auth_user->pid,
|
|
], [
|
|
], [
|
|
'authorizer_refresh_token' => $authorizer_refresh_token
|
|
'authorizer_refresh_token' => $authorizer_refresh_token
|
|
]);
|
|
]);
|
|
@@ -64,22 +73,14 @@ class WechatOpenPlatformController extends CatchController
|
|
*/
|
|
*/
|
|
public function authorCommand(Request $request, $component_appid) {
|
|
public function authorCommand(Request $request, $component_appid) {
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
- myLog('authorCommand')->info('start:'. $component_appid);
|
|
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
- $app->setCache(Cache::store('redis'));
|
|
|
|
- $server = $app->getServer();
|
|
|
|
-
|
|
|
|
- $server->handleVerifyTicketRefreshed(function($message, \Closure $next) {
|
|
|
|
- myLog('authorCommand')->info('handleVerifyTicketRefreshed', ['message' => $message]);
|
|
|
|
- return $next($message);
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
+ $server = $app->getServer();
|
|
|
|
|
|
$server->handleAuthorized(function($message, \Closure $next) {
|
|
$server->handleAuthorized(function($message, \Closure $next) {
|
|
myLog('authorCommand')->info('handleAuthorized', ['message' => $message]);
|
|
myLog('authorCommand')->info('handleAuthorized', ['message' => $message]);
|
|
return $next($message);
|
|
return $next($message);
|
|
});
|
|
});
|
|
- myLog('authorCommand')->info('end00000');
|
|
|
|
|
|
|
|
return $server->serve();
|
|
return $server->serve();
|
|
}
|
|
}
|