Skip to content

Commit

Permalink
Fix for app:enable in case of not valid/not existing enterprise key
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Nov 11, 2019
1 parent 5503eb7 commit b3353dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion core/Command/App/Enable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace OC\Core\Command\App;

use OCP\IConfig;
use OCP\App\IAppManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -36,12 +37,17 @@ class Enable extends Command {
/** @var IAppManager */
protected $manager;

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

/**
* @param IAppManager $manager
* @param IConfig $config
*/
public function __construct(IAppManager $manager) {
public function __construct(IAppManager $manager, IConfig $config) {
parent::__construct();
$this->manager = $manager;
$this->config = $config;
}

protected function configure() {
Expand Down Expand Up @@ -71,10 +77,21 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}

$groups = $input->getOption('groups');
if (\OC_App::isEnabled('enterprise_key')) {
$key = new \OCA\Enterprise_Key\EnterpriseKey(false, $this->config);
}
if (empty($groups)) {
if ($key && !$key->isValid()) {
$output->writeln($appId . ' cannot be enabled because of invalid enteprise key');
return 1;
}
\OC_App::enable($appId);
$output->writeln($appId . ' enabled');
} else {
if ($key && !$key->isValid()) {
$output->writeln($appId . ' cannot be enabled because of invalid enteprise key');
return 1;
}
\OC_App::enable($appId, $groups);
$output->writeln($appId . ' enabled for groups: ' . \implode(', ', $groups));
}
Expand Down
2 changes: 1 addition & 1 deletion core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager()));
$application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager()));
$application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\App\GetPath());
$application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));

Expand Down

0 comments on commit b3353dd

Please sign in to comment.