improve status messages
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
28a7e72868
commit
5f75468aa4
|
@ -196,7 +196,8 @@ class Application extends \OCP\AppFramework\App {
|
|||
$c->getAppName(),
|
||||
$server->getRequest(),
|
||||
$server->getL10N($c->getAppName()),
|
||||
$c->query('Session')
|
||||
$c->query('Session'),
|
||||
$server->getEncryptionManager()
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace OCA\Encryption\Controller;
|
|||
use OCA\Encryption\Session;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
@ -39,20 +40,26 @@ class StatusController extends Controller {
|
|||
/** @var Session */
|
||||
private $session;
|
||||
|
||||
/** @var IManager */
|
||||
private $encryptionManager;
|
||||
|
||||
/**
|
||||
* @param string $AppName
|
||||
* @param IRequest $request
|
||||
* @param IL10N $l10n
|
||||
* @param Session $session
|
||||
* @param IManager $encryptionManager
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IL10N $l10n,
|
||||
Session $session
|
||||
Session $session,
|
||||
IManager $encryptionManager
|
||||
) {
|
||||
parent::__construct($AppName, $request);
|
||||
$this->l = $l10n;
|
||||
$this->session = $session;
|
||||
$this->encryptionManager = $encryptionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,9 +85,15 @@ class StatusController extends Controller {
|
|||
break;
|
||||
case Session::NOT_INITIALIZED:
|
||||
$status = 'interactionNeeded';
|
||||
$message = (string)$this->l->t(
|
||||
'Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.'
|
||||
);
|
||||
if ($this->encryptionManager->isEnabled()) {
|
||||
$message = (string)$this->l->t(
|
||||
'Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.'
|
||||
);
|
||||
} else {
|
||||
$message = (string)$this->l->t(
|
||||
'Please enable server side encryption in the admin settings in order to use the encryption module.'
|
||||
);
|
||||
}
|
||||
break;
|
||||
case Session::INIT_SUCCESSFUL:
|
||||
$status = 'success';
|
||||
|
|
|
@ -7,7 +7,7 @@ style('encryption', 'settings-admin');
|
|||
?>
|
||||
<form id="ocDefaultEncryptionModule" class="sub-section">
|
||||
<h3><?php p($l->t("Default encryption module")); ?></h3>
|
||||
<?php if(!$_["initStatus"]): ?>
|
||||
<?php if(!$_["initStatus"] && $_['masterKeyEnabled'] === false): ?>
|
||||
<?php p($l->t("Encryption app is enabled but your keys are not initialized, please log-out and log-in again")); ?>
|
||||
<?php else: ?>
|
||||
<p id="encryptHomeStorageSetting">
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace OCA\Encryption\Tests\Controller;
|
|||
|
||||
use OCA\Encryption\Controller\StatusController;
|
||||
use OCA\Encryption\Session;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\IRequest;
|
||||
use Test\TestCase;
|
||||
|
||||
|
@ -41,6 +42,9 @@ class StatusControllerTest extends TestCase {
|
|||
/** @var \OCA\Encryption\Session | \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $sessionMock;
|
||||
|
||||
/** @var IManager | \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $encryptionManagerMock;
|
||||
|
||||
/** @var StatusController */
|
||||
protected $controller;
|
||||
|
||||
|
@ -59,11 +63,13 @@ class StatusControllerTest extends TestCase {
|
|||
->will($this->returnCallback(function($message) {
|
||||
return $message;
|
||||
}));
|
||||
$this->encryptionManagerMock = $this->createMock(IManager::class);
|
||||
|
||||
$this->controller = new StatusController('encryptionTest',
|
||||
$this->requestMock,
|
||||
$this->l10nMock,
|
||||
$this->sessionMock);
|
||||
$this->sessionMock,
|
||||
$this->encryptionManagerMock);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue