Skip to content

Commit

Permalink
feat(backend): new AuthService GetClientInfo method
Browse files Browse the repository at this point in the history
  • Loading branch information
TyIsI committed Dec 2, 2024
1 parent e69d8c2 commit b178f1d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/contracts/IAuthService1.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public function GetAccessToken($bearerToken);
*/
public function GetClient($clientId, $clientSecret);

/**
* @permission oauth-provider
*
* @param $clientId
* @param $clientSecret
*
* @return mixed
*/
public function GetClientInfo($clientId);

/**
* @permission oauth-provider
*
Expand Down
33 changes: 32 additions & 1 deletion app/services/AuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public function GetAccessToken($bearerToken) {
}

/**
* @permission oauth-provider
* @permission anonymous
*
* @param $clientId
* @param $clientSecret
Expand All @@ -387,6 +387,24 @@ public function GetClient($clientId, $clientSecret) {
return null;
}

/**
* @permission oauth-provider
* @permission authenticated
*
* @param $clientId
*
* @return mixed
*/
public function GetClientInfo($clientId) {
$client = AppClient::find($clientId);

if (!is_null($client)) {
return $this->trimClientInfo($client);
}

return null;
}

/**
* @permission oauth-provider
*
Expand Down Expand Up @@ -738,6 +756,19 @@ private function trimClient($client) {
];
}

private function trimClientInfo($client) {
if (is_null($client)) {
return null;
}

return [
'name' => $client->name,
'description' => $client->description,
'url' => $client->url,
'redirecturi' => $client->redirecturi
];
}

private function trimUser($user) {
if (is_null($user)) {
return null;
Expand Down

0 comments on commit b178f1d

Please sign in to comment.