summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-09-06 12:27:40 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-09-06 12:27:40 +0200
commitfb462e83ccde5c46565c23545c5eb894acbd6fd3 (patch)
tree4b334e82c8e61247419f4120b18922fc923f5cf7 /apps
parent69b1625f0e368e65771fef473f4b4d4a13456354 (diff)
downloadnextcloud-server-fb462e83ccde5c46565c23545c5eb894acbd6fd3.tar.gz
nextcloud-server-fb462e83ccde5c46565c23545c5eb894acbd6fd3.zip
no longer enforce log out, but provide useful errors/warnings instead
Diffstat (limited to 'apps')
-rw-r--r--apps/files/index.php7
-rw-r--r--apps/files/js/files.js9
-rw-r--r--apps/files/templates/index.php1
-rw-r--r--apps/files_encryption/ajax/updatePrivateKeyPassword.php1
-rw-r--r--apps/files_encryption/appinfo/app.php17
-rw-r--r--apps/files_encryption/hooks/hooks.php2
-rwxr-xr-xapps/files_encryption/lib/helper.php27
-rw-r--r--apps/files_encryption/lib/session.php15
-rw-r--r--apps/files_encryption/lib/stream.php2
-rw-r--r--apps/files_encryption/lib/util.php3
-rw-r--r--apps/files_encryption/templates/invalid_private_key.php6
11 files changed, 42 insertions, 48 deletions
diff --git a/apps/files/index.php b/apps/files/index.php
index f1e120c872c..b81ba2bdde9 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -124,8 +124,12 @@ if ($needUpgrade) {
$storageInfo=OC_Helper::getStorageInfo($dir);
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
$publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
+ // if the encryption app is disabled, than everything is fine
+ $encryptionInitStatus = \OCA\Encryption\Session::INIT_SUCCESSFUL;
if (OC_App::isEnabled('files_encryption')) {
$publicUploadEnabled = 'no';
+ $session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
+ $encryptionInitStatus = $session->getInitialized();
}
$trashEnabled = \OCP\App::isEnabled('files_trashbin');
@@ -133,7 +137,7 @@ if ($needUpgrade) {
if ($trashEnabled) {
$trashEmpty = \OCA\Files_Trashbin\Trashbin::isEmpty($user);
}
-
+
OCP\Util::addscript('files', 'fileactions');
OCP\Util::addscript('files', 'files');
OCP\Util::addscript('files', 'keyboardshortcuts');
@@ -153,5 +157,6 @@ if ($needUpgrade) {
$tmpl->assign('isPublic', false);
$tmpl->assign('publicUploadEnabled', $publicUploadEnabled);
$tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles());
+ $tmpl->assign("encryptionInitStatus", $encryptionInitStatus);
$tmpl->printPage();
}
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index d729077ea72..63c3544b53d 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -90,6 +90,15 @@ Files={
}
var encryptedFiles = $('#encryptedFiles').val();
+ var initStatus = $('#encryptionInitStatus').val();
+ if (initStatus === '0') { // enc not initialized, but should be
+ OC.Notification.show(t('files_encryption', 'Encryption App is enabled but your keys are not initialized, please log-out and log-in again'));
+ return;
+ }
+ if (initStatus === '1') { // encryption tried to init but failed
+ OC.Notification.show(t('files_encryption', 'Your private key is not valid! Likely your password was changed outside the ownCloud system (e.g. your corporate directory). You can update your private key password in your personal settings to recover access to your encrypted files.'));
+ return;
+ }
if (encryptedFiles === '1') {
OC.Notification.show(t('files_encryption', 'Encryption was disabled but your files are still encrypted. Please go to your personal settings to decrypt your files.'));
return;
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 24cb8c2fe58..e17273e47b1 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -123,3 +123,4 @@
<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php p($_['allowZipDownload']); ?>" />
<input type="hidden" name="usedSpacePercent" id="usedSpacePercent" value="<?php p($_['usedSpacePercent']); ?>" />
<input type="hidden" name="encryptedFiles" id="encryptedFiles" value="<?php $_['encryptedFiles'] ? p('1') : p('0'); ?>" />
+<input type="hidden" name="encryptedFiles" id="encryptionInitStatus" value="<?php p($_['encryptionInitStatus']) ?>" /> \ No newline at end of file
diff --git a/apps/files_encryption/ajax/updatePrivateKeyPassword.php b/apps/files_encryption/ajax/updatePrivateKeyPassword.php
index 1e6644da576..29c72952ae9 100644
--- a/apps/files_encryption/ajax/updatePrivateKeyPassword.php
+++ b/apps/files_encryption/ajax/updatePrivateKeyPassword.php
@@ -48,6 +48,7 @@ if ($decryptedKey) {
// success or failure
if ($return) {
+ $session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL);
\OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.'))));
} else {
\OCP\JSON::error(array('data' => array('message' => $l->t('Could not update the private key password. Maybe the old password was not correct.'))));
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index 90a9984e27f..cd26cd10cd9 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -41,23 +41,6 @@ if (!OC_Config::getValue('maintenance', false)) {
if($sessionReady) {
$session = new \OCA\Encryption\Session($view);
}
-
- $user = \OCP\USER::getUser();
- // check if user has a private key
- if ($sessionReady === false
- || (!$view->file_exists('/' . $user . '/files_encryption/' . $user . '.private.key')
- && OCA\Encryption\Crypt::mode() === 'server')
- ) {
-
- // Force the user to log-in again if the encryption key isn't unlocked
- // (happens when a user is logged in before the encryption app is
- // enabled)
- OCP\User::logout();
-
- header("Location: " . OC::$WEBROOT . '/');
-
- exit();
- }
}
} else {
// logout user if we are in maintenance to force re-login
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 4c6122b7c2b..c945deeea0c 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -547,7 +547,7 @@ class Hooks {
$setMigrationStatus->execute();
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
- $session->setInitialized(false);
+ $session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);
}
}
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index 7d466b88523..048473ce846 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -237,28 +237,15 @@ class Helper {
*/
public static function redirectToErrorPage($session) {
- $l = \OC_L10N::get('files_encryption');
-
- if ($session->getInitialized() === false) {
- $errorMsg = $l->t('Encryption app not initialized! Maybe the encryption app was re-enabled during your session. Please try to log out and log back in to initialize the encryption app.');
- } else {
- $errorMsg = $l->t('Your private key is not valid! Likely your password was changed outside the ownCloud system (e.g. your corporate directory). You can update your private key password in your personal settings to recover access to your encrypted files.');
- }
+ $init = $session->getInitialized();
+ $location = \OC_Helper::linkToAbsolute('apps/files_encryption/files', 'error.php');
+ $post = 0;
if(count($_POST) > 0) {
- header('HTTP/1.0 404 ' . $errorMsg);
- }
-
- // check if ajax request
- if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
- \OCP\JSON::error(array('data' => array('message' => $errorMsg)));
- } else {
- header('HTTP/1.0 404 ' . $errorMsg);
- $tmpl = new OC_Template('files_encryption', 'invalid_private_key', 'guest');
- $tmpl->printPage();
- }
-
- exit;
+ $post = 1;
+ }
+ header('Location: ' . $location . '?p=' . $post . '&i=' . $init);
+ exit();
}
/**
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 648e6e9ab07..25f2198181f 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -30,6 +30,11 @@ class Session {
private $view;
+ const NOT_INITIALIZED = '0';
+ const INIT_EXECUTED = '1';
+ const INIT_SUCCESSFUL = '2';
+
+
/**
* @brief if session is started, check if ownCloud key pair is set up, if not create it
* @param \OC_FilesystemView $view
@@ -113,10 +118,10 @@ class Session {
}
/**
- * @brief Sets status if we tried to initialize the encyption app
- * @param bool $privateKey true=initialized false=not initialized
+ * @brief Sets status of encryption app
+ * @param string $init INIT_SUCCESSFUL, INIT_EXECUTED, NOT_INOITIALIZED
* @return bool
- *
+ *
* @note this doesn not indicate of the init was successful, we just remeber the try!
*/
public function setInitialized($init) {
@@ -130,7 +135,7 @@ class Session {
/**
* @brief Gets status if we already tried to initialize the encryption app
- * @returns bool
+ * @returns init status INIT_SUCCESSFUL, INIT_EXECUTED, NOT_INOITIALIZED
*
* @note this doesn not indicate of the init was successful, we just remeber the try!
*/
@@ -138,7 +143,7 @@ class Session {
if (!is_null(\OC::$session->get('encryptionInitialized'))) {
return \OC::$session->get('encryptionInitialized');
} else {
- return false;
+ return self::NOT_INITIALIZED;
}
}
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 9215352aa78..c6db10ce40d 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -128,7 +128,7 @@ class Stream {
$this->unencryptedSize = 0;
} else {
-
+\OCA\Encryption\Helper::redirectToErrorPage($this->session);
if($this->privateKey === false) {
// if private key is not valid redirect user to a error page
\OCA\Encryption\Helper::redirectToErrorPage($this->session);
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 17096a787f2..7a19f954643 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1724,7 +1724,7 @@ class Util {
$session = new \OCA\Encryption\Session($this->view);
// we tried to initialize the encryption app for this session
- $session->setInitialized(true);
+ $session->setInitialized(\OCA\Encryption\Session::INIT_EXECUTED);
$encryptedKey = Keymanager::getPrivateKey($this->view, $params['uid']);
@@ -1737,6 +1737,7 @@ class Util {
}
$session->setPrivateKey($privateKey);
+ $session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL);
return $session;
}
diff --git a/apps/files_encryption/templates/invalid_private_key.php b/apps/files_encryption/templates/invalid_private_key.php
index 5c086d6514c..9af65f831b4 100644
--- a/apps/files_encryption/templates/invalid_private_key.php
+++ b/apps/files_encryption/templates/invalid_private_key.php
@@ -2,9 +2,11 @@
<li class='error'>
<?php $location = \OC_Helper::linkToRoute( "settings_personal" ).'#changePKPasswd' ?>
- <?php p($l->t('Your private key is not valid! Maybe the your password was changed from outside.')); ?>
+ <?php p($_['message']); ?>
<br/>
- <?php p($l->t('You can unlock your private key in your ')); ?> <a href="<?php echo $location?>"><?php p($l->t('personal settings')); ?>.</a>
+ <?php if($_['init']): ?>
+ <?php>p($l->t('Go directly to your ')); ?> <a href="<?php echo $location?>"><?php p($l->t('personal settings')); ?>.</a>
+ <?php endif; ?>
<br/>
</li>
</ul>