瀏覽代碼

make recovery settings work

tags/v8.1.0alpha1
Bjoern Schiessle 9 年之前
父節點
當前提交
a85e2e0bfd

+ 3
- 8
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();
}


apps/encryption/appinfo/encryption.php → 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();

+ 4
- 4
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'
]

+ 2
- 2
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);

+ 1
- 1
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;

+ 0
- 3
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();

+ 4
- 2
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>

+ 4
- 1
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)) {

+ 12
- 0
lib/public/iservercontainer.php 查看文件

@@ -172,6 +172,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
*

Loading…
取消
儲存