Merge branch 'smallFixes'

This commit is contained in:
brantje 2017-01-03 21:43:13 +01:00
commit a8d1299785
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
13 changed files with 32 additions and 44 deletions

View file

@ -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){

View file

@ -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)'),

View file

@ -149,6 +149,6 @@ class VaultController extends ApiController {
* @NoCSRFRequired
*/
public function delete($vault_id) {
return;
return new JSONResponse($vault_id);
}
}

View file

@ -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;
}

View file

@ -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)
}
)
}

View file

@ -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);
}

View file

@ -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')
}
)
}

View file

@ -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'));

View file

@ -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);
}

View file

@ -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");
}
}

View file

@ -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'));
}
}
}
}

View file

@ -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;
}

View file

@ -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();
}
}