Skip to content

Commit

Permalink
Update MsGraph.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bajramemini committed Jan 16, 2025
1 parent bccc551 commit ceb4f26
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/MsGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,14 @@ public function connect(?string $id = null): Redirector|RedirectResponse
throw new Exception($errorMessage);
}

if (auth()->check()) {
$this->storeToken(
$accessToken->getToken(),
$accessToken->getRefreshToken(),
$accessToken->getExpires(),
$id,
auth()->user()->email
null,
);
} else {

$response = Http::withToken($accessToken->getToken())->get(self::$baseUrl.'me');

event(new NewMicrosoft365SignInEvent([
'info' => $response->json(),
'accessToken' => $accessToken->getToken(),
'refreshToken' => $accessToken->getRefreshToken(),
'expires' => $accessToken->getExpires(),
]));
}

}

return redirect(config('msgraph.msgraphLandingUri'));
Expand Down Expand Up @@ -276,7 +265,7 @@ public function __call(string $function, array $args)
$path = (isset($args[0])) ? $args[0] : '';
$data = (isset($args[1])) ? $args[1] : [];
$headers = (isset($args[2])) ? $args[2] : [];
$id = (isset($args[3])) ? $args[3] : auth()->id();
$id = (isset($args[3])) ? $args[3] : null;

if (in_array($function, $options)) {
return self::guzzle($function, $path, $data, $headers, $id);
Expand Down Expand Up @@ -352,7 +341,7 @@ protected function getUserId(?string $id = null): ?string
}

if ($id === null) {
$id = auth()->id();
// $id = auth()->id();
}

return $id;
Expand Down

0 comments on commit ceb4f26

Please sign in to comment.