Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/user_saml.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-04 18:50:09 +0300
committerblizzz (Rebase PR Action) <blizzz@users.noreply.github.com>2022-04-07 23:29:03 +0300
commitc51048b5666e6846fc520154f6248165a2da08ed (patch)
treed8ad6514bf380e56352d0eda3247aab0bdaed533 /lib/Command
parent24a632588caa53a8a657ba5a0d01bd7b4941381e (diff)
Minor fixes
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/Command')
-rw-r--r--lib/Command/ConfigDelete.php15
-rw-r--r--lib/Command/ConfigSet.php15
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/Command/ConfigDelete.php b/lib/Command/ConfigDelete.php
index 09310dee..2ccd6ff4 100644
--- a/lib/Command/ConfigDelete.php
+++ b/lib/Command/ConfigDelete.php
@@ -28,6 +28,7 @@ namespace OCA\User_SAML\Command;
use OC\Core\Command\Base;
use OCA\User_SAML\SAMLSettings;
+use OCP\DB\Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -53,7 +54,19 @@ class ConfigDelete extends Base {
protected function execute(InputInterface $input, OutputInterface $output): int {
$pId = (int)$input->getArgument('providerId');
- $this->samlSettings->delete($pId);
+
+ if ((string)$pId !== $input->getArgument('providerId')) {
+ // Make sure we don't delete provider with id 0 by error
+ $output->writeln('<error>providerId argument needs to be an number. Got: ' . $pId . '</error>');
+ return 1;
+ }
+ try {
+ $this->samlSettings->delete($pId);
+ $output->writeln('Provider deleted.');
+ } catch (Exception $e) {
+ $output->writeln('<error>Provider with id: ' . $providerId . ' does not exist.</error>');
+ return 1;
+ }
return 0;
}
}
diff --git a/lib/Command/ConfigSet.php b/lib/Command/ConfigSet.php
index 8f55f8bc..1e0a577f 100644
--- a/lib/Command/ConfigSet.php
+++ b/lib/Command/ConfigSet.php
@@ -28,6 +28,7 @@ namespace OCA\User_SAML\Command;
use OC\Core\Command\Base;
use OCA\User_SAML\SAMLSettings;
+use OCP\DB\Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -65,7 +66,18 @@ class ConfigSet extends Base {
protected function execute(InputInterface $input, OutputInterface $output): int {
$pId = (int)$input->getArgument('providerId');
- $settings = $this->samlSettings->get($pId);
+
+ if ((string)$pId !== $input->getArgument('providerId')) {
+ // Make sure we don't delete provider with id 0 by error
+ $output->writeln('<error>providerId argument needs to be an number. Got: ' . $pId . '</error>');
+ return 1;
+ }
+ try {
+ $settings = $this->samlSettings->get($pId);
+ } catch (Exception $e) {
+ $output->writeln('<error>Provider with id: ' . $providerId . ' does not exist.</error>');
+ return 1;
+ }
foreach ($input->getOptions() as $key => $value) {
if (!in_array($key, SAMLSettings::IDP_CONFIG_KEYS) || $value === null) {
@@ -78,6 +90,7 @@ class ConfigSet extends Base {
$settings[$key] = $value;
}
$this->samlSettings->set($pId, $settings);
+ $output->writeln('The provider\'s config was updated.');
return 0;
}