diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-03-30 11:49:03 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:28 +0200 |
commit | a85e2e0bfdb86de029f7b5fde42ead60498aed82 (patch) | |
tree | dfd3ef5d49e3be52e533e2ecd95547f8a08f41ec | |
parent | 4aa125cc0a2b5a129c4f97d807f7a225a7620199 (diff) | |
download | nextcloud-server-a85e2e0bfdb86de029f7b5fde42ead60498aed82.tar.gz nextcloud-server-a85e2e0bfdb86de029f7b5fde42ead60498aed82.zip |
make recovery settings work
-rw-r--r-- | apps/encryption/appinfo/app.php | 11 | ||||
-rw-r--r-- | apps/encryption/appinfo/application.php (renamed from apps/encryption/appinfo/encryption.php) | 28 | ||||
-rw-r--r-- | apps/encryption/appinfo/routes.php | 8 | ||||
-rw-r--r-- | apps/encryption/js/settings-admin.js | 4 | ||||
-rw-r--r-- | apps/encryption/lib/keymanager.php | 2 | ||||
-rw-r--r-- | apps/encryption/settings/settings-admin.php | 3 | ||||
-rw-r--r-- | apps/encryption/templates/settings-admin.php | 6 | ||||
-rw-r--r-- | lib/private/encryption/manager.php | 5 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 12 |
9 files changed, 45 insertions, 34 deletions
diff --git a/apps/encryption/appinfo/app.php b/apps/encryption/appinfo/app.php index 72e7fc42ca0..38f9ff2f040 100644 --- a/apps/encryption/appinfo/app.php +++ b/apps/encryption/appinfo/app.php @@ -19,15 +19,10 @@ * */ -use OCA\Encryption\AppInfo\Encryption; +namespace OCA\Encryption\AppInfo; -if (!OC::$CLI) { +if (!\OC::$CLI) { $di = \OC::$server; - $app = new Encryption('encryption', - [], - $di->getEncryptionManager(), - $di->getConfig()); - - $app->boot(); + $app = new Application(); } diff --git a/apps/encryption/appinfo/encryption.php b/apps/encryption/appinfo/application.php index 6aad9219025..606c0cc5c49 100644 --- a/apps/encryption/appinfo/encryption.php +++ b/apps/encryption/appinfo/application.php @@ -36,7 +36,7 @@ use OCP\Encryption\IManager; use OCP\IConfig; -class Encryption extends \OCP\AppFramework\App { +class Application extends \OCP\AppFramework\App { /** * @var IManager */ @@ -49,19 +49,11 @@ class Encryption extends \OCP\AppFramework\App { /** * @param $appName * @param array $urlParams - * @param IManager $encryptionManager - * @param IConfig $config */ - public function __construct($appName, $urlParams = array(), IManager $encryptionManager, IConfig $config) { - parent::__construct($appName, $urlParams); - $this->encryptionManager = $encryptionManager; - $this->config = $config; - } - - /** - * - */ - public function boot() { + public function __construct($urlParams = array()) { + parent::__construct('encryption', $urlParams); + $this->encryptionManager = \OC::$server->getEncryptionManager(); + $this->config = \OC::$server->getConfig(); $this->registerServices(); $this->registerEncryptionModule(); $this->registerHooks(); @@ -153,6 +145,16 @@ class Encryption extends \OCP\AppFramework\App { $server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID)); }); + $container->registerService('RecoveryController', function (IAppContainer $c) { + $server = $c->getServer(); + return new \OCA\Encryption\Controller\RecoveryController( + $c->getAppName(), + $server->getRequest(), + $server->getConfig(), + $server->getL10N($c->getAppName()), + $c->query('Recovery')); + }); + $container->registerService('UserSetup', function (IAppContainer $c) { $server = $c->getServer(); diff --git a/apps/encryption/appinfo/routes.php b/apps/encryption/appinfo/routes.php index a86f3717ce9..b2c00c83349 100644 --- a/apps/encryption/appinfo/routes.php +++ b/apps/encryption/appinfo/routes.php @@ -20,17 +20,17 @@ */ -use OCP\AppFramework\App; +namespace OCA\Encryption\AppInfo; -(new App('encryption'))->registerRoutes($this, array('routes' => array( +(new Application())->registerRoutes($this, array('routes' => array( [ - 'name' => 'recovery#adminRecovery', + 'name' => 'Recovery#adminRecovery', 'url' => '/ajax/adminRecovery', 'verb' => 'POST' ], [ - 'name' => 'recovery#userRecovery', + 'name' => 'Recovery#userRecovery', 'url' => '/ajax/userRecovery', 'verb' => 'POST' ] diff --git a/apps/encryption/js/settings-admin.js b/apps/encryption/js/settings-admin.js index 2242c1f7124..e5d3bebb208 100644 --- a/apps/encryption/js/settings-admin.js +++ b/apps/encryption/js/settings-admin.js @@ -17,7 +17,7 @@ $(document).ready(function(){ var confirmPassword = $( '#repeatEncryptionRecoveryPassword' ).val(); OC.msg.startSaving('#encryptionSetRecoveryKey .msg'); $.post( - OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' ) + OC.generateUrl('/apps/encryption/ajax/adminRecovery') , { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword, confirmPassword: confirmPassword } , function( result ) { OC.msg.finishedSaving('#encryptionSetRecoveryKey .msg', result); @@ -44,7 +44,7 @@ $(document).ready(function(){ var confirmNewPassword = $('#repeatedNewEncryptionRecoveryPassword').val(); OC.msg.startSaving('#encryptionChangeRecoveryKey .msg'); $.post( - OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' ) + OC.filePath( 'encryption', 'ajax', 'changeRecoveryPassword.php' ) , { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword, confirmPassword: confirmNewPassword } , function( data ) { OC.msg.finishedSaving('#encryptionChangeRecoveryKey .msg', data); diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index b3961c8566e..68fb722c5ea 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -193,7 +193,7 @@ class KeyManager { if ($encryptedKey) { $this->setPrivateKey($uid, $encryptedKey); - $this->config->setAppValue('encryption', 'recoveryAdminEnabled', 1); + $this->config->setAppValue('encryption', 'recoveryAdminEnabled', 0); return true; } return false; diff --git a/apps/encryption/settings/settings-admin.php b/apps/encryption/settings/settings-admin.php index 813956aa0af..a34d30d1de5 100644 --- a/apps/encryption/settings/settings-admin.php +++ b/apps/encryption/settings/settings-admin.php @@ -18,7 +18,4 @@ $recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 're $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled); $tmpl->assign('initStatus', KeyManager::$session->get('initStatus')); -\OCP\Util::addscript('files_encryption', 'settings-admin'); -\OCP\Util::addscript('core', 'multiselect'); - return $tmpl->fetchPage(); diff --git a/apps/encryption/templates/settings-admin.php b/apps/encryption/templates/settings-admin.php index 252701e9ed0..616c593f6fb 100644 --- a/apps/encryption/templates/settings-admin.php +++ b/apps/encryption/templates/settings-admin.php @@ -1,6 +1,8 @@ <?php - /** @var array $_ */ - /** @var OC_L10N $l */ +/** @var array $_ */ +/** @var OC_L10N $l */ +script('encryption', 'settings-admin'); +script('core', 'multiselect'); ?> <form id="encryption" class="section"> <h2><?php p($l->t('ownCloud basic encryption module')); ?></h2> diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php index fa50d32218d..7cd49d1c0e2 100644 --- a/lib/private/encryption/manager.php +++ b/lib/private/encryption/manager.php @@ -66,12 +66,15 @@ class Manager implements \OCP\Encryption\IManager { public function registerEncryptionModule(IEncryptionModule $module) { $id = $module->getId(); $name = $module->getDisplayName(); + + // FIXME why do we load the same encryption module multiple times + /* if (isset($this->encryptionModules[$id])) { $message = 'Id "' . $id . '" already used by encryption module "' . $name . '"'; throw new Exceptions\ModuleAlreadyExistsException($message); } - +*/ $defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId(); if (empty($defaultEncryptionModuleId)) { diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index d7df884adf8..2db1fc32499 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -173,6 +173,18 @@ interface IServerContainer { function getL10N($app, $lang = null); /** + * @return \OC\Encryption\Manager + */ + function getEncryptionManager(); + + /** + * @param string $encryptionModuleId encryption module ID + * + * @return \OCP\Encryption\Keys\IStorage + */ + function getEncryptionKeyStorage($encryptionModuleId); + + /** * Returns the URL generator * * @return \OCP\IURLGenerator |