Skip to content

Commit

Permalink
Fixed #1995
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Dec 23, 2020
1 parent 5e9f48e commit 4ff1574
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/OpenPlatform/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace EasyWeChat\OpenPlatform;

use EasyWeChat\Kernel\ServiceContainer;
use EasyWeChat\Kernel\Traits\ResponseCastable;
use EasyWeChat\MiniProgram\Encryptor;
use EasyWeChat\OpenPlatform\Authorizer\Auth\AccessToken;
use EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Application as MiniProgram;
Expand All @@ -37,6 +38,8 @@
*/
class Application extends ServiceContainer
{
use ResponseCastable;

/**
* @var array
*/
Expand Down Expand Up @@ -139,7 +142,8 @@ public function getPreAuthorizationUrl(string $callbackUrl, $optional = []): str
'pre_auth_code' => $optional,
];
} else {
$optional['pre_auth_code'] = $this->createPreAuthorizationCode()['pre_auth_code'];
$response = $this->detectAndCastResponseToType($this->createPreAuthorizationCode(), 'array');
$optional['pre_auth_code'] = $response['pre_auth_code'];
}

$queries = \array_merge($optional, [
Expand All @@ -166,7 +170,8 @@ public function getMobilePreAuthorizationUrl(string $callbackUrl, $optional = []
'pre_auth_code' => $optional,
];
} else {
$optional['pre_auth_code'] = $this->createPreAuthorizationCode()['pre_auth_code'];
$response = $this->detectAndCastResponseToType($this->createPreAuthorizationCode(), 'array');
$optional['pre_auth_code'] = $response['pre_auth_code'];
}

$queries = \array_merge(['auth_type' => 3], $optional, [
Expand Down
5 changes: 5 additions & 0 deletions src/OpenPlatform/Server/Handlers/VerifyTicketRefreshed.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace EasyWeChat\OpenPlatform\Server\Handlers;

use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
use EasyWeChat\Kernel\Traits\ResponseCastable;
use EasyWeChat\OpenPlatform\Application;

/**
Expand All @@ -21,6 +22,8 @@
*/
class VerifyTicketRefreshed implements EventHandlerInterface
{
use ResponseCastable;

/**
* @var \EasyWeChat\OpenPlatform\Application
*/
Expand All @@ -41,6 +44,8 @@ public function __construct(Application $app)
*/
public function handle($payload = null)
{
$payload = $this->detectAndCastResponseToType($payload, 'array');

if (!empty($payload['ComponentVerifyTicket'])) {
$this->app['verify_ticket']->setTicket($payload['ComponentVerifyTicket']);
}
Expand Down

0 comments on commit 4ff1574

Please sign in to comment.