Skip to content

Commit cfb16d5

Browse files
author
justmd5
committed
增强兼容性,移动端网页授权,授权url如果view为空,view直接赋值h5
1 parent 86e5bcb commit cfb16d5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/Oauth/PreAuth.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@ private function accessToken()
5757
*/
5858
public function authorizationUrl(string $state = null, string $view = null): string
5959
{
60+
$memberType = strtoupper($this->app->getConfig('member_type'));
61+
if (!array_key_exists($memberType, static::AUTHORIZE_API_ARR)) {
62+
throw new \InvalidArgumentException('Invalid member type');
63+
}
6064
return sprintf(
6165
'%s?%s',
62-
static::AUTHORIZE_API_ARR[strtoupper($this->app->getConfig('member_type'))],
66+
static::AUTHORIZE_API_ARR[$memberType],
6367
http_build_query([
6468
'client_id' => $this->accessToken()->getClientId(),
6569
'response_type' => 'code',
6670
'state' => $state,
6771
'redirect_uri' => $this->accessToken()->getRedirectUri(),
68-
'view' => $view,
72+
'view' => $memberType === 'H5' ? 'h5' : $view,
6973
])
7074
);
7175
}

0 commit comments

Comments
 (0)