Check if shared_key exists

Remove value set by php

Replace DoesNotExistException with Exeption
This commit is contained in:
brantje 2016-12-29 00:07:27 +01:00
parent 80973c77a8
commit 9ab74be344
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
6 changed files with 27 additions and 25 deletions

View file

@ -192,7 +192,7 @@ class CredentialController extends ApiController {
try {
$acl_list = $this->sharingService->getCredentialAclList($storedCredential->getGuid());
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
// Just check if we have an acl list
}
if (!empty($acl_list)) {
@ -270,7 +270,7 @@ class CredentialController extends ApiController {
public function getRevision($credential_guid) {
try {
$credential = $this->credentialService->getCredentialByGUID($credential_guid);
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundJSONResponse();
}
@ -306,13 +306,13 @@ class CredentialController extends ApiController {
$revision = null;
try {
$this->credentialService->getCredentialByGUID($credential_guid, $this->userId);
} catch (DoesNotExistException $e) {
} catch (\Exception $e) {
return new NotFoundJSONResponse();
}
try {
$revision = $this->credentialRevisionService->getRevision($revision_id);
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
return new NotFoundJSONResponse();
}

View file

@ -62,7 +62,7 @@ class FileController extends ApiController {
public function updateFile($file_id, $file_data, $filename, $mimetype, $size){
try{
$file = $this->fileService->getFile($file_id, $this->userId);
} catch (DoesNotExistException $doesNotExistException){
} catch (\Exception $doesNotExistException){
}
if($file){

View file

@ -96,13 +96,13 @@ class ShareController extends ApiController {
try {
$credential = $this->credentialService->getCredentialByGUID($item_guid);
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
return new NotFoundResponse();
}
try {
$acl = $this->shareService->getACL(null, $item_guid);
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
$acl = new SharingACL();
}
@ -145,14 +145,14 @@ class ShareController extends ApiController {
if (count($shareRequests) > 0) {
return new JSONResponse(array('error' => 'User got already pending requests'));
}
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
// no need to catch this
}
$acl = null;
try {
$acl = $this->shareService->getCredentialAclForUser($first_vault['user_id'], $item_guid);
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
// no need to catch this
}
@ -247,12 +247,12 @@ class ShareController extends ApiController {
$sr = null;
try {
$acl = $this->shareService->getCredentialAclForUser($user_id, $item_guid);
} catch (DoesNotExistException $e) {
} catch (\Exception $e) {
}
try {
$sr = array_pop($this->shareService->getPendingShareRequestsForCredential($item_guid, $user_id));
} catch (DoesNotExistException $e) {
} catch (\Exception $e) {
// no need to catch this
}
@ -307,7 +307,7 @@ class ShareController extends ApiController {
public function savePendingRequest($item_guid, $target_vault_guid, $final_shared_key) {
try {
$sr = $this->shareService->getRequestByGuid($item_guid, $target_vault_guid);
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundResponse();
}
@ -348,7 +348,7 @@ class ShareController extends ApiController {
array_push($results, $result);
}
return new JSONResponse($results);
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundResponse();
}
}
@ -362,7 +362,7 @@ class ShareController extends ApiController {
public function getRevisions($item_guid) {
try {
return new JSONResponse($this->shareService->getItemHistory($this->userId, $item_guid));
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundJSONResponse();
}
}
@ -378,7 +378,7 @@ class ShareController extends ApiController {
try {
return new JSONResponse($this->shareService->getSharedItems($this->userId->getUID(), $vault_guid));
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundResponse();
}
}
@ -413,7 +413,7 @@ class ShareController extends ApiController {
$this->shareService->cleanItemRequestsForUser($sr);
return new JSONResponse(array('result' => true));
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundJSONResponse();
}
}
@ -447,7 +447,7 @@ class ShareController extends ApiController {
try {
$credential = $this->shareService->getSharedItem(null, $credential_guid);
return new JSONResponse($credential);
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new NotFoundJSONResponse();
}
}
@ -472,7 +472,7 @@ class ShareController extends ApiController {
} else {
return new NotFoundResponse();
}
} catch (DoesNotExistException $ex) {
} catch (\Exception $ex) {
return new JSONResponse(array());
}
}
@ -488,7 +488,7 @@ class ShareController extends ApiController {
public function getFile($item_guid, $file_guid) {
try {
$credential = $this->credentialService->getCredentialByGUID($item_guid);
} catch (DoesNotExistException $e) {
} catch (\Exception $e) {
return new NotFoundJSONResponse();
}
$userId = ($this->userId) ? $this->userId->getUID() : null;
@ -511,7 +511,7 @@ class ShareController extends ApiController {
public function updateSharedCredentialACL($item_guid, $user_id, $permission) {
try {
$credential = $this->credentialService->getCredentialByGUID($item_guid);
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
return new NotFoundJSONResponse();
}
if ($this->userId->getUID() === $credential->getUserId()) {
@ -520,7 +520,7 @@ class ShareController extends ApiController {
$acl = $this->shareService->getACL($user_id, $item_guid);
$acl->setPermissions($permission);
return $this->shareService->updateCredentialACL($acl);
} catch (DoesNotExistException $exception) {
} catch (\Exception $exception) {
}

View file

@ -86,7 +86,7 @@ class VaultController extends ApiController {
$vault = null;
try {
$vault = $this->vaultService->getByGuid($vault_guid, $this->userId);
} catch (DoesNotExistException $e) {
} catch (\Exception $e) {
return new NotFoundJSONResponse();
}
$result = array();
@ -136,7 +136,7 @@ class VaultController extends ApiController {
$vault = null;
try {
$vault = $this->vaultService->getByGuid($vault_guid, $this->userId);
} catch (DoesNotExistException $e) {
} catch (\Exception $e) {
}

View file

@ -131,7 +131,9 @@ class CredentialMapper extends Mapper {
$credential->setCustomFields($raw_credential['custom_fields']);
$credential->setOtp($raw_credential['otp']);
$credential->setHidden($raw_credential['hidden']);
$credential->setSharedKey($raw_credential['shared_key']);
if(isset($raw_credential['shared_key'])) {
$credential->setSharedKey($raw_credential['shared_key']);
}
return parent::insert($credential);
}

View file

@ -52,7 +52,7 @@ if ($checkVersion) {
<p>
<input type="checkbox" name="passman_sharing_enabled"
id="passman_sharing_enabled" class="checkbox"
value="1" <?php if ($_['user_sharing_enabled']) print_unescaped('checked="checked"'); ?> />
value="1" />
<label for="passman_sharing_enabled">
<?php p($l->t('Allow users on this server to share passwords with other users')); ?>
</label>