Skip to content

Commit

Permalink
Merge pull request #624 from nextcloud/automated/noid/master-update-n…
Browse files Browse the repository at this point in the history
…extcloud-ocp
  • Loading branch information
provokateurin authored Mar 13, 2024
2 parents 8d052e8 + 7cb1548 commit 06fe58d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function registerSites(

foreach ($sites as $site) {
if ($site['type'] === SitesManager::TYPE_QUOTA) {
$settingsManager->registerSetting(IManager::KEY_PERSONAL_SETTINGS, Personal::class);
$settingsManager->registerSetting(IManager::SETTINGS_PERSONAL, Personal::class);
continue;
}

Expand Down
18 changes: 9 additions & 9 deletions lib/JWTManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
use OCA\External\AppInfo\Application;
use OCA\External\Vendor\Firebase\JWT\JWT;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\IURLGenerator;

class JWTManager {
protected IConfig $config;
protected IAppConfig $config;
protected ITimeFactory $timeFactory;
protected IURLGenerator $urlGenerator;

public function __construct(IConfig $config,
public function __construct(IAppConfig $config,
ITimeFactory $timeFactory,
IURLGenerator $urlGenerator) {
$this->config = $config;
Expand Down Expand Up @@ -70,7 +70,7 @@ public function getTokenPublicKey(?string $alg = null): string {
}
$this->ensureTokenKeys($alg);

return $this->config->getAppValue(Application::APP_ID, 'jwt_token_pubkey_' . strtolower($alg));
return $this->config->getValueString(Application::APP_ID, 'jwt_token_pubkey_' . strtolower($alg));
}

protected function getTokenPrivateKey(?string $alg = null): string {
Expand All @@ -79,11 +79,11 @@ protected function getTokenPrivateKey(?string $alg = null): string {
}
$this->ensureTokenKeys($alg);

return $this->config->getAppValue(Application::APP_ID, 'jwt_token_privkey_' . strtolower($alg));
return $this->config->getValueString(Application::APP_ID, 'jwt_token_privkey_' . strtolower($alg));
}

protected function ensureTokenKeys(string $alg): void {
$secret = $this->config->getAppValue(Application::APP_ID, 'jwt_token_privkey_' . strtolower($alg));
$secret = $this->config->getValueString(Application::APP_ID, 'jwt_token_privkey_' . strtolower($alg));
if ($secret) {
return;
}
Expand Down Expand Up @@ -117,11 +117,11 @@ protected function ensureTokenKeys(string $alg): void {
throw new \Exception('Unsupported algorithm ' . $alg);
}

$this->config->setAppValue(Application::APP_ID, 'jwt_token_privkey_' . strtolower($alg), $secret);
$this->config->setAppValue(Application::APP_ID, 'jwt_token_pubkey_' . strtolower($alg), $public);
$this->config->setValueString(Application::APP_ID, 'jwt_token_privkey_' . strtolower($alg), $secret);
$this->config->setValueString(Application::APP_ID, 'jwt_token_pubkey_' . strtolower($alg), $public);
}

protected function getTokenAlgorithm(): string {
return $this->config->getAppValue(Application::APP_ID, 'jwt_token_alg', 'ES256');
return $this->config->getValueString(Application::APP_ID, 'jwt_token_alg', 'ES256');
}
}
22 changes: 11 additions & 11 deletions lib/SitesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IUser;
Expand All @@ -55,7 +55,7 @@ class SitesManager {
/** @var IRequest */
protected $request;

/** @var IConfig */
/** @var IAppConfig */
protected $config;

/** @var IFactory */
Expand All @@ -78,7 +78,7 @@ class SitesManager {


public function __construct(IRequest $request,
IConfig $config,
IAppConfig $config,
IAppManager $appManager,
IGroupManager $groupManager,
IUserSession $userSession,
Expand Down Expand Up @@ -166,7 +166,7 @@ public function getSitesToDisplay() {
* @return array[]
*/
public function getSites() {
$jsonEncodedList = $this->config->getAppValue('external', 'sites', '');
$jsonEncodedList = $this->config->getValueString('external', 'sites', '');
$sites = json_decode($jsonEncodedList, true);

if (!is_array($sites) || empty($sites)) {
Expand Down Expand Up @@ -217,7 +217,7 @@ protected function fillSiteArray(array $site): array {
* @throws IconNotFoundException
*/
public function addSite($name, $url, $lang, $type, $device, $icon, array $groups, $redirect) {
$id = 1 + (int) $this->config->getAppValue('external', 'max_site', '0');
$id = 1 + $this->config->getValueInt('external', 'max_site');

if ($name === '') {
throw new InvalidNameException();
Expand Down Expand Up @@ -282,8 +282,8 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups
'groups' => $groups,
'redirect' => $redirect,
];
$this->config->setAppValue('external', 'sites', json_encode($sites));
$this->config->setAppValue('external', 'max_site', (string)$id);
$this->config->setValueString('external', 'sites', json_encode($sites));
$this->config->setValueInt('external', 'max_site', $id);

return $sites[$id];
}
Expand Down Expand Up @@ -376,7 +376,7 @@ public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array
'groups' => $groups,
'redirect' => $redirect,
];
$this->config->setAppValue('external', 'sites', json_encode($sites));
$this->config->setValueString('external', 'sites', json_encode($sites));

return $sites[$id];
}
Expand All @@ -388,7 +388,7 @@ public function deleteSite(int $id): void {
}

unset($sites[$id]);
$this->config->setAppValue('external', 'sites', json_encode($sites));
$this->config->setValueString('external', 'sites', json_encode($sites));
}

/**
Expand All @@ -407,8 +407,8 @@ protected function getSitesFromOldConfig(array $sites): array {
]);
}

$this->config->setAppValue('external', 'sites', json_encode($fixedSites));
$this->config->setAppValue('external', 'max_site', (string)max(array_keys($fixedSites)));
$this->config->setValueString('external', 'sites', json_encode($fixedSites));
$this->config->setValueInt('external', 'max_site', max(array_keys($fixedSites)));
return $fixedSites;
}

Expand Down

0 comments on commit 06fe58d

Please sign in to comment.