summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2013-08-01 07:43:50 -0700
committerBjörn Schießle <bjoern@schiessle.org>2013-08-01 07:43:50 -0700
commit930f0e4c1824405f2be8144187613271fe169c73 (patch)
tree4224214f8c7bc55340a738a8f815d1c96e0ed818 /apps
parent77dad7070dfa77fd564172e3791af45f843d7f33 (diff)
parent69173c2a6bad0646efcebe9815fbd18c57665ebd (diff)
downloadnextcloud-server-930f0e4c1824405f2be8144187613271fe169c73.tar.gz
nextcloud-server-930f0e4c1824405f2be8144187613271fe169c73.zip
Merge pull request #4270 from owncloud/fix_4253
cancel sharing if some users doesn't have a working encryption set-up.
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/hooks/hooks.php16
-rwxr-xr-xapps/files_encryption/tests/share.php9
2 files changed, 14 insertions, 11 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index b2a17f6bca5..741df166b70 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -238,6 +238,7 @@ class Hooks {
*/
public static function preShared($params) {
+ $l = new \OC_L10N('files_encryption');
$users = array();
$view = new \OC\Files\View('/public-keys/');
@@ -250,21 +251,18 @@ class Hooks {
break;
}
- $error = false;
+ $notConfigured = array();
foreach ($users as $user) {
if (!$view->file_exists($user . '.public.key')) {
- $error = true;
- break;
+ $notConfigured[] = $user;
}
}
- if ($error) // Set flag var 'run' to notify emitting
- // script that hook execution failed
- {
- $params['run']->run = false;
+ if (count($notConfigured) > 0) {
+ $params['run'] = false;
+ $params['error'] = $l->t('Following users are not set up for encryption:') . ' ' . join(', ' , $notConfigured);
}
- // TODO: Make sure files_sharing provides user
- // feedback on failed share
+
}
/**
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index ebf678da78e..5f3d5005090 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -881,8 +881,13 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
\OC_FileProxy::$enabled = $proxyStatus;
// share the file
- \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, OCP\PERMISSION_ALL);
-
+ try {
+ \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, OCP\PERMISSION_ALL);
+ } catch (Exception $e) {
+ $this->assertEquals(0, strpos($e->getMessage(), "Following users are not set up for encryption"));
+ }
+
+
// login as admin
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);