修改微信app授权

This commit is contained in:
liu 2024-03-18 14:33:38 +08:00
parent 04474ac0e4
commit d540906498

View File

@ -559,8 +559,10 @@ class Auth extends BaseController
return $user;
} else if ($auth['type'] === 'app_wechat') {
$oauth = WechatService::create()->getApplication()->oauth;
$accessToken = $oauth->getAccessToken($data['code']);
try {
$wechatInfo = $oauth->user(new AccessToken(['access_token' => $data['code'], 'openid' => $data['openid']]))->getOriginal();
// $wechatInfo = $oauth->user(new AccessToken(['access_token' => $data['code'], 'openid' => $data['openid']]))->getOriginal();
$wechatInfo = $oauth->user($accessToken)->getOriginal();
} catch (Exception $e) {
throw new ValidateException('授权失败[001]' . $e->getMessage());
}
@ -568,7 +570,8 @@ class Auth extends BaseController
if (!$user)
throw new ValidateException('授权失败');
return $user;
} else if ($auth['type'] === 'apple') {
}
else if ($auth['type'] === 'apple') {
$identityToken = $data['userInfo']['identityToken'];
$tks = explode('.', $identityToken);
if (count($tks) != 3) {
@ -597,7 +600,7 @@ class Auth extends BaseController
*/
public function authLogin()
{
$auth = $this->request->param('auth');
$auth = $this->request->param('auth'); dump($auth);
$createUser = true;
if ($auth['type'] == 'app_wechat' || systemConfig('is_phone_login') == '1') {
$createUser = false;
@ -996,10 +999,17 @@ class Auth extends BaseController
$agent = strtolower($this->request->server('HTTP_USER_AGENT'));
// 检查是否为iOS设备包括iPhone和iPad
if (strpos($agent, 'iphone') !== false || strpos($agent, 'ipad') !== false) {
$appInfo=[];
$appInfo = Db::name('AppUpdate')->where('type', $type)->order('id','desc')->find();
} elseif (strpos($agent, 'android') !== false) {
// 检查是否为Android设备
$appInfo = Db::name('AppUpdate')->where('type', $type)->order('id','desc')->find();
if($agent == 'ios'){
$pattern = '/\.wgt$/i';
if (preg_match($pattern, basename($appInfo['dow_url']))) {
$appInfo =[];
}
}
} else {
$appInfo=[];
// 如果都不是,则输出其他