diff options
Diffstat (limited to 'apps/oauth2/lib/Settings/Admin.php')
-rw-r--r-- | apps/oauth2/lib/Settings/Admin.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/oauth2/lib/Settings/Admin.php b/apps/oauth2/lib/Settings/Admin.php index 948306f8857..9c7ffb9e18d 100644 --- a/apps/oauth2/lib/Settings/Admin.php +++ b/apps/oauth2/lib/Settings/Admin.php @@ -22,12 +22,40 @@ declare(strict_types=1); namespace OCA\OAuth2\Settings; +use OCA\OAuth2\Db\ClientMapper; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IInitialStateService; use OCP\Settings\ISettings; class Admin implements ISettings { + /** @var IInitialStateService */ + private $initialStateService; + + /** @var ClientMapper */ + private $clientMapper; + + public function __construct(IInitialStateService $initialStateService, + ClientMapper $clientMapper) { + $this->initialStateService = $initialStateService; + $this->clientMapper = $clientMapper; + } + public function getForm(): TemplateResponse { + $clients = $this->clientMapper->getClients(); + $result = []; + + foreach ($clients as $client) { + $result[] = [ + 'id' => $client->getId(), + 'name' => $client->getName(), + 'redirectUri' => $client->getRedirectUri(), + 'clientId' => $client->getClientIdentifier(), + 'clientSecret' => $client->getSecret(), + ]; + } + $this->initialStateService->provideInitialState('oauth2', 'clients', $result); + return new TemplateResponse( 'oauth2', 'admin', |