|
@@ -26,6 +26,7 @@ use Hashids;
|
|
|
use GuzzleHttp\Client;
|
|
|
use App\Jobs\SendTexts;
|
|
|
use DB;
|
|
|
+use EasyWeChat\Foundation\Application;
|
|
|
|
|
|
class ReadOauth
|
|
|
{
|
|
@@ -41,6 +42,7 @@ class ReadOauth
|
|
|
}
|
|
|
|
|
|
$uid_cookie = Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
|
|
|
+ if($uid_cookie) $uid_cookie = $this->authCallBack($request);
|
|
|
$h5_scheme = env('H5_SCHEME', 'https');
|
|
|
$params = $request->except('_url');
|
|
|
$url = str_replace('http://', $h5_scheme . '://', url()->current() . '?' . http_build_query($params));
|
|
@@ -65,49 +67,39 @@ class ReadOauth
|
|
|
return response($this->notAccessPage())->header('Content-Type', 'text/html');
|
|
|
}
|
|
|
}
|
|
|
+ $uri_send_order_id = 0;
|
|
|
$uri = $request->input('_url');
|
|
|
+ if (strpos($uri, '/yun/') !== false) {
|
|
|
+ $uri_send_order_id = (int)str_ireplace('/yun/', '', $uri);
|
|
|
+ }
|
|
|
+ $yun = $request->get('yun');
|
|
|
+ $yun && $uri_send_order_id = $yun;
|
|
|
if (!$uid_cookie && $test == 0) {
|
|
|
- //$url = str_replace('http://','https://',url()->current())."?".http_build_query($params);
|
|
|
-
|
|
|
- if (strpos($uri, '/yun/') !== false) {
|
|
|
- $uri_send_order_id = (int)str_ireplace('/yun/', '', $uri);
|
|
|
+ $params = [];
|
|
|
+ if($uri_send_order_id){
|
|
|
Cookie::queue('send_order_id', $uri_send_order_id, env('U_COOKIE_EXPIRE'), null, null, false, false);
|
|
|
}
|
|
|
-
|
|
|
$this->share($request);
|
|
|
-
|
|
|
Cookie::queue('auth_redirect', urlencode($url), env('U_COOKIE_EXPIRE'));
|
|
|
-
|
|
|
- //$params['redirect_url'] = urlencode(env('PUBLIC_BASE_API').'oauthCallBack');
|
|
|
- //$params['redirect_url'] = urlencode('http://47.96.174.172:8093/oauthCallBack');
|
|
|
- $domain = _domain();
|
|
|
- $params['redirect_url'] = urlencode($h5_scheme . '://' . $domain . '/oauthCallBack');
|
|
|
-
|
|
|
+ $params['redirect_url'] = urlencode($url);
|
|
|
$params['timestamp'] = time();
|
|
|
-
|
|
|
- //$office_info = $this->getOfficialAccount(_domain());
|
|
|
- //$params['gzh_app_id'] = $office_info['appid'];
|
|
|
+ $params['channel_id'] = $distribution_channel_id;
|
|
|
$params['gzh_app_id'] = env('WECHAT_AUTH_APPID');
|
|
|
-
|
|
|
+ $params['sid'] = $uri_send_order_id;
|
|
|
$params['sign'] = $this->getSign($params, env('OAUTH_KEY'));
|
|
|
|
|
|
$redirect = env('AUTH_URL') . '?' . http_build_query($params);
|
|
|
|
|
|
- $auth_v2_url = $this->authV2($request, $distribution_channel_id);
|
|
|
+ /*$auth_v2_url = $this->authV2($request, $distribution_channel_id);
|
|
|
if ($auth_v2_url) {
|
|
|
return redirect()->to($auth_v2_url);
|
|
|
}
|
|
|
$redirect_V2 = $this->auth($request, $distribution_channel_id);
|
|
|
if ($redirect_V2) {
|
|
|
return redirect()->to($redirect_V2);
|
|
|
- }
|
|
|
+ }*/
|
|
|
return redirect()->to($redirect);
|
|
|
}
|
|
|
- $uri_send_order_id = 0;
|
|
|
- if (strpos($uri, '/yun/') !== false) {
|
|
|
- $uri_send_order_id = (int)str_ireplace('/yun/', '', $uri);
|
|
|
- //Redis::hset('book_read:' . $uid_cookie, 'send_order_id', $uri_send_order_id);
|
|
|
- }
|
|
|
|
|
|
//个性化推送
|
|
|
$this->stylePush($request,$uid_cookie,$distribution_channel_id);
|
|
@@ -1097,4 +1089,19 @@ class ReadOauth
|
|
|
WapVisitStatService::specialChannelIdStatsMarkUser($uid,$bid,$send_order_id);
|
|
|
return ;
|
|
|
}
|
|
|
+
|
|
|
+ private function authCallBack(Request $request){
|
|
|
+ $auth_uid = $request->get('auth_uid');
|
|
|
+ $atime = $request->get('atime');
|
|
|
+ $sign = $request->get('sign');
|
|
|
+ if(!$auth_uid || !$atime || !$sign) return 0;
|
|
|
+
|
|
|
+ if(!is_numeric($auth_uid) || !is_numeric($atime)) return 0;
|
|
|
+
|
|
|
+ if( (time()-$atime) >20) return 0;
|
|
|
+
|
|
|
+ if(get_sign(compact('auth_uid','atime')) !== $sign ) return 0;
|
|
|
+ Cookie::queue(env('COOKIE_AUTH_WEB_WECHAT'), $auth_uid, env('U_COOKIE_EXPIRE'), null, null, false, false);
|
|
|
+ return $auth_uid;
|
|
|
+ }
|
|
|
}
|