diff --git a/controller/filecontroller.php b/controller/filecontroller.php index d3c29ea5..368e1c87 100644 --- a/controller/filecontroller.php +++ b/controller/filecontroller.php @@ -59,7 +59,7 @@ class FileController extends ApiController { return new JSONResponse($this->fileService->deleteFile($file_id, $this->userId)); } - public function updateFile($file_id, $file_data, $filename, $mimetype, $size){ + public function updateFile($file_id, $file_data, $filename){ try{ $file = $this->fileService->getFile($file_id, $this->userId); } catch (\Exception $doesNotExistException){ diff --git a/controller/translationcontroller.php b/controller/translationcontroller.php index 96659e98..088f310a 100644 --- a/controller/translationcontroller.php +++ b/controller/translationcontroller.php @@ -33,7 +33,7 @@ class TranslationController extends ApiController { * @NoCSRFRequired * @PublicPage */ - public function getLanguageStrings($lang) { + public function getLanguageStrings() { $translations = array( // js/app/controllers/bookmarklet.js 'generating.sharing.keys' => $this->trans->t('Generating sharing keys ( %step / 2)'), diff --git a/controller/vaultcontroller.php b/controller/vaultcontroller.php index c206a39e..4891aa6c 100644 --- a/controller/vaultcontroller.php +++ b/controller/vaultcontroller.php @@ -149,6 +149,6 @@ class VaultController extends ApiController { * @NoCSRFRequired */ public function delete($vault_id) { - return; + return new JSONResponse($vault_id); } } \ No newline at end of file diff --git a/js/importers/import-main.js b/js/importers/import-main.js index bf727c08..277de202 100644 --- a/js/importers/import-main.js +++ b/js/importers/import-main.js @@ -29,11 +29,11 @@ var PassmanImporter = {}; // Strip leading quote. row = row.trim(); var isQuoted = false; - if (row.charAt(0) == '"') { + if (row.charAt(0) === '"') { row = row.substring(1); isQuoted = true; } - if (row.charAt(row.length - 2) == '"') { + if (row.charAt(row.length - 2) === '"') { row = row.substring(0, row.length - 2); isQuoted = true; } diff --git a/js/importers/importer-clipperz.js b/js/importers/importer-clipperz.js index 156dc4a5..37092f93 100644 --- a/js/importers/importer-clipperz.js +++ b/js/importers/importer-clipperz.js @@ -61,7 +61,7 @@ var PassmanImporter = PassmanImporter || {}; { 'label': field_data.label, 'value': field_data.value, - 'secret': (field_data.hidden == true) + 'secret': (field_data.hidden === true) } ) } diff --git a/js/importers/importer-dashlanecsv.js b/js/importers/importer-dashlanecsv.js index 0ad1308a..e9d17551 100644 --- a/js/importers/importer-dashlanecsv.js +++ b/js/importers/importer-dashlanecsv.js @@ -42,11 +42,11 @@ var PassmanImporter = PassmanImporter || {}; for (var i = 0; i < rows.length; i++) { var row = rows[i]; var row_data = row.split('","'); - if (row_data[0].charAt(0) == '"') { + if (row_data[0].charAt(0) === '"') { row_data[0] = row_data[0].substring(1); } - if (row_data[row_data.length-1].toString().charAt(row_data[row_data.length - 1].length - 1) == '"') { + if (row_data[row_data.length-1].toString().charAt(row_data[row_data.length - 1].length - 1) === '"') { row_data[row_data.length - 1] = row_data[row_data.length -1].substring(0, row_data[row_data.length - 1].length - 1); } diff --git a/js/importers/importer-passmanjson.js b/js/importers/importer-passmanjson.js index 1020e766..3df91d92 100644 --- a/js/importers/importer-passmanjson.js +++ b/js/importers/importer-passmanjson.js @@ -57,7 +57,7 @@ var PassmanImporter = PassmanImporter || {}; { 'label': item.customFields[cf].label, 'value': item.customFields[cf].value, - 'secret': (item.customFields[cf].clicktoshow == '1') + 'secret': (item.customFields[cf].clicktoshow === '1') } ) } diff --git a/js/settings-admin.js b/js/settings-admin.js index 960753b2..f9225069 100644 --- a/js/settings-admin.js +++ b/js/settings-admin.js @@ -90,11 +90,11 @@ $(document).ready(function () { // ADMIN SETTINGS // fill the boxes - $('#passman_link_sharing_enabled').prop('checked', (settings.getKey('link_sharing_enabled').toString().toLowerCase() == '1')); - $('#passman_sharing_enabled').prop('checked', (settings.getKey('user_sharing_enabled').toString().toLowerCase() == '1')); - $('#passman_check_version').prop('checked', (settings.getKey('check_version').toString().toLowerCase() == '1')); - $('#passman_https_check').prop('checked', (settings.getKey('https_check').toString().toLowerCase() == '1')); - $('#passman_disable_contextmenu').prop('checked', (settings.getKey('disable_contextmenu').toString().toLowerCase() == '1')); + $('#passman_link_sharing_enabled').prop('checked', (settings.getKey('link_sharing_enabled').toString().toLowerCase() === '1')); + $('#passman_sharing_enabled').prop('checked', (settings.getKey('user_sharing_enabled').toString().toLowerCase() === '1')); + $('#passman_check_version').prop('checked', (settings.getKey('check_version').toString().toLowerCase() === '1')); + $('#passman_https_check').prop('checked', (settings.getKey('https_check').toString().toLowerCase() === '1')); + $('#passman_disable_contextmenu').prop('checked', (settings.getKey('disable_contextmenu').toString().toLowerCase() === '1')); $('#vault_key_strength').val(settings.getKey('vault_key_strength')); diff --git a/lib/Db/SharingACLMapper.php b/lib/Db/SharingACLMapper.php index 66246426..e251a0c4 100644 --- a/lib/Db/SharingACLMapper.php +++ b/lib/Db/SharingACLMapper.php @@ -60,13 +60,11 @@ class SharingACLMapper extends Mapper { public function getItemACL($user_id, $item_guid) { $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND "; $filter = [$item_guid]; - if ($user_id === null){ - $q .= 'user_id is null'; - } - else { - $q .= 'user_id = ? '; - $filter[] = $user_id; + $q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? '; + if ($user_id !== null){ + $filter[] = $user_id; } + return $this->findEntity($q, $filter); } diff --git a/lib/Service/CredentialService.php b/lib/Service/CredentialService.php index 3fb61113..9590bb0e 100644 --- a/lib/Service/CredentialService.php +++ b/lib/Service/CredentialService.php @@ -125,9 +125,8 @@ class CredentialService { $acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid()); if ($acl->hasPermission(SharingACL::READ)) { return $credential; - } else { - throw new DoesNotExistException("Did expect one result but found none when executing"); } + throw new DoesNotExistException("Did expect one result but found none when executing"); } } diff --git a/lib/Service/CronService.php b/lib/Service/CronService.php index 3ee3660e..ca114166 100644 --- a/lib/Service/CronService.php +++ b/lib/Service/CronService.php @@ -65,10 +65,7 @@ class CronService { '', array(), $link, $credential->getUserId(), Activity::TYPE_ITEM_EXPIRED); $this->notificationService->credentialExpiredNotification($credential); - } else { - $this->logger->debug($credential->getLabel() .' is expired, already notified!', array('app' => 'passman')); } - } } } \ No newline at end of file diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index ae486373..813a994e 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -39,7 +39,8 @@ class SettingsService { 'vault_key_strength', 'check_version', 'https_check', - 'disable_contextmenu' + 'disable_contextmenu', + 'settings_loaded' ); public function __construct($UserId, IConfig $config, $AppName) { @@ -74,14 +75,11 @@ class SettingsService { * @return mixed */ public function getAppSetting($key, $default_value = null) { - if (isset($this->settings[$key])) { - $value = $this->settings[$key]; - if (in_array($key, $this->numeric_settings)) { - $value = intval($value); - } - } else { - $value = $this->config->getAppValue('passman', $key, $default_value); + $value = ($this->settings[$key]) ? $this->settings[$key] : $this->config->getAppValue('passman', $key, $default_value); + if (in_array($key, $this->numeric_settings)) { + $value = intval($value); } + return $value; } diff --git a/middleware/sharemiddleware.php b/middleware/sharemiddleware.php index f95cbbca..35553316 100644 --- a/middleware/sharemiddleware.php +++ b/middleware/sharemiddleware.php @@ -19,19 +19,15 @@ class ShareMiddleware extends Middleware { public function beforeController($controller, $methodName) { if ($controller instanceof ShareController) { - $http_response_code = \OCP\AppFramework\Http::STATUS_FORBIDDEN; - $result = 'FORBIDDEN'; + $http_response_code = Http::STATUS_OK; + $result = array(); + $publicMethods = array('createPublicShare', 'getPublicCredentialData'); + $user_pub_methods = array('updateSharedCredentialACL', 'getFile', 'getItemAcl'); + $setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled'; + $sharing_enabled = ($this->settings->isEnabled($setting)); - if (in_array($methodName, array('updateSharedCredentialACL', 'getFile', 'getItemAcl'))) { + if(in_array($methodName, $user_pub_methods)){ $sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled')); - } else { - $publicMethods = array('createPublicShare', 'getPublicCredentialData'); - $setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled'; - $sharing_enabled = ($this->settings->isEnabled($setting)); - if ($methodName === 'getVaultItems' || $methodName === 'getPendingRequests') { - $http_response_code = Http::STATUS_OK; - $result = array(); - } }