소스 검색

auth reduce redircet debug 5

zz 6 년 전
부모
커밋
5da2c279ea
1개의 변경된 파일25개의 추가작업 그리고 2개의 파일을 삭제
  1. 25 2
      app/Http/Middleware/ReadOauth.php

+ 25 - 2
app/Http/Middleware/ReadOauth.php

@@ -82,10 +82,12 @@ class ReadOauth
             }
             $this->share($request);
             Cookie::queue('auth_redirect', urlencode($url), env('U_COOKIE_EXPIRE'));
+            $appid = env('WECHAT_AUTH_APPID');
             $params['redirect_url'] = urlencode($url);
             $params['timestamp'] = time();
             $params['channel_id'] = $distribution_channel_id;
-            $params['gzh_app_id'] = env('WECHAT_AUTH_APPID');
+            $params['gzh_app_id'] = $appid;
+            $params['appid'] = $appid;
             $params['sid'] = $uri_send_order_id;
             $params['sign'] = $this->getSign($params, env('OAUTH_KEY'));
 
@@ -99,7 +101,28 @@ class ReadOauth
             if ($redirect_V2) {
                 return redirect()->to($redirect_V2);
             }*/
-            return redirect()->to($redirect);
+
+            $info = DB::table('official_setting')->where('appid',$appid)->select('secret')->first();
+            if($info && $info->secret){
+                $secter = $info->secre;
+            }else{
+                $secter = '';
+                abort(404);
+            }
+
+            $options = [
+                'app_id'=>env('WECHAT_AUTH_APPID'),
+                'secret'=>$secter,
+                'oauth' => [
+                    'scopes'   => ['snsapi_base'],
+                    'callback' => env('AUTH_CALLBACK_URL').'?'.http_build_query($params),
+                ],
+            ];
+            Log::info('$options is:');
+            Log::info($options);
+            $app = new Application($options);
+            return $app->oauth->redirect();
+            //return redirect()->to($redirect);
         }
 
         //个性化推送