Skip to content

Commit d174bd6

Browse files
committed
Assign access_token
1 parent ceeb545 commit d174bd6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/SS14/Endpoints/OAuth2Endpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ private function get(
120120
$OAA->removeToken($response, $headers, $body);
121121
return;
122122
}
123-
if (isset($params['user']) && $user = $OAA->getUser()) {
123+
if (isset($params['user'])) {
124124
$response = Response::STATUS_OK;
125125
$headers = ['Content-Type' => 'application/json'];
126-
$body = json_encode($user);
126+
$body = json_encode($OAA->getUser() ?? []);
127127
return;
128128
}
129129
}

src/VerifierServer/OAuth2Authenticator.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ public function getToken(
197197
string $redirect_uri = ''
198198
): ?string
199199
{
200+
if (!empty($this->access_token)) {
201+
$response = Response::STATUS_FOUND;
202+
$headers = ['Location' => $this->redirect_home];
203+
$body = '';
204+
return $this->access_token;
205+
}
200206
if (! isset($this->issuer, $this->token_endpoint)) {
201207
$response = Response::STATUS_BAD_REQUEST;
202208
$headers = ['Content-Type' => 'text/plain'];
@@ -232,12 +238,12 @@ public function getToken(
232238
$response = Response::STATUS_FOUND;
233239
$headers = ['Location' => $this->redirect_home];
234240
$body = '';
235-
return $this->sessions[$this->endpoint_name][$this->requesting_ip]['access_token'] = $api_response->access_token;
241+
return $this->sessions[$this->endpoint_name][$this->requesting_ip]['access_token'] = $this->access_token = $api_response->access_token;
236242
}
237243

238244
public function getUser(): ?object
239245
{
240-
if (isset($this->user)) {
246+
if (!empty($this->user)) {
241247
return $this->sessions[$this->endpoint_name][$this->requesting_ip]['user'] = $this->user;
242248
}
243249
if (! isset($this->issuer, $this->userinfo_endpoint, $this->access_token)) {

0 commit comments

Comments
 (0)