Skip to content

Commit 52e46ef

Browse files
Fixed callback controller storage of tenants (#73)
Co-authored-by: [email protected] <[email protected]>
1 parent b54e137 commit 52e46ef

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Controllers/AuthorizationCallbackController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ public function __invoke(Request $request, OauthCredentialManager $oauth, Identi
2626

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

31-
$oauth->store($accessToken, $tenantId);
30+
//Iterate tenants
31+
$tenants = array();
32+
foreach($identity->getConnections() as $c) {
33+
$tenants[] = [
34+
"Id" => $c->getTenantId(),
35+
"Name"=> $c->getTenantName()
36+
];
37+
}
38+
39+
//Store Token and Tenants
40+
$oauth->store($accessToken, $tenants);
3241
Event::dispatch(new XeroAuthorized($oauth->getData()));
3342

3443
return $this->onSuccess();

0 commit comments

Comments
 (0)