summaryrefslogtreecommitdiffstats
path: root/apps/oauth2/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/oauth2/lib')
-rw-r--r--apps/oauth2/lib/Controller/SettingsController.php18
-rw-r--r--apps/oauth2/lib/Settings/Admin.php28
2 files changed, 28 insertions, 18 deletions
diff --git a/apps/oauth2/lib/Controller/SettingsController.php b/apps/oauth2/lib/Controller/SettingsController.php
index ecf3179e1bc..3b79c7de594 100644
--- a/apps/oauth2/lib/Controller/SettingsController.php
+++ b/apps/oauth2/lib/Controller/SettingsController.php
@@ -103,22 +103,4 @@ class SettingsController extends Controller {
$this->clientMapper->delete($client);
return new JSONResponse([]);
}
-
- public function getClients(): JSONResponse {
- $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(),
- ];
- }
-
- return new JSONResponse($result);
- }
}
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',