Skip to content

Commit

Permalink
Fixed callback controller storage of tenants (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: agallop@celestra.co.uk <agallop@celestra.co.uk>
  • Loading branch information
AllanGallop and SatansFosterSon authored Jul 10, 2022
1 parent b54e137 commit 52e46ef
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Controllers/AuthorizationCallbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@ public function __invoke(Request $request, OauthCredentialManager $oauth, Identi

$accessToken = $provider->getAccessToken('authorization_code', $request->only('code'));
$identity->getConfig()->setAccessToken((string)$accessToken->getToken());
$tenantId = $identity->getConnections()[0]->getTenantId();

$oauth->store($accessToken, $tenantId);
//Iterate tenants
$tenants = array();
foreach($identity->getConnections() as $c) {
$tenants[] = [
"Id" => $c->getTenantId(),
"Name"=> $c->getTenantName()
];
}

//Store Token and Tenants
$oauth->store($accessToken, $tenants);
Event::dispatch(new XeroAuthorized($oauth->getData()));

return $this->onSuccess();
Expand Down

0 comments on commit 52e46ef

Please sign in to comment.