mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-26 21:35:57 +08:00
Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
cee3ea9865
commit
33ef75ac2f
5 changed files with 147 additions and 115 deletions
|
|
@ -43,23 +43,39 @@ class CredentialService {
|
|||
public function updateCredential($credential) {
|
||||
return $this->credentialMapper->updateCredential($credential);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Credential $credential
|
||||
*/
|
||||
public function upd($credential) {
|
||||
return $this->credentialMapper->upd($credential);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Credential $credential
|
||||
*/
|
||||
public function deleteCredential($credential){
|
||||
return $this->credentialMapper->deleteCredential($credential);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $vault_id
|
||||
*/
|
||||
public function getCredentialsByVaultId($vault_id, $user_id) {
|
||||
return $this->credentialMapper->getCredentialsByVaultId($vault_id, $user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $vault_id
|
||||
*/
|
||||
public function getRandomCredentialByVaultId($vault_id, $user_id) {
|
||||
$credentials = $this->credentialMapper->getRandomCredentialByVaultId($vault_id, $user_id);
|
||||
return array_pop($credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $timestamp
|
||||
*/
|
||||
public function getExpiredCredentials($timestamp) {
|
||||
return $this->credentialMapper->getExpiredCredentials($timestamp);
|
||||
}
|
||||
|
|
@ -77,6 +93,10 @@ class CredentialService {
|
|||
|
||||
throw new DoesNotExistException("Did expect one result but found none when executing");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $credential_id
|
||||
*/
|
||||
public function getCredentialLabelById($credential_id){
|
||||
return $this->credentialMapper->getCredentialLabelById($credential_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,9 @@ class ShareService {
|
|||
}
|
||||
|
||||
public function createACLEntry(SharingACL $acl) {
|
||||
if ($acl->getCreated() === null) $acl->setCreated((new \DateTime())->getTimestamp());
|
||||
if ($acl->getCreated() === null) {
|
||||
$acl->setCreated((new \DateTime())->getTimestamp());
|
||||
}
|
||||
return $this->sharingACL->createACLEntry($acl);
|
||||
}
|
||||
|
||||
|
|
@ -124,12 +126,16 @@ class ShareService {
|
|||
$return = [];
|
||||
foreach ($entries as $entry) {
|
||||
// Check if the user can read the credential, probably unnecesary, but just to be sure
|
||||
if (!$entry->hasPermission(SharingACL::READ)) continue;
|
||||
if (!$entry->hasPermission(SharingACL::READ)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmp = $entry->jsonSerialize();
|
||||
$tmp['credential_data'] = $this->credential->getCredentialById($entry->getItemId())->jsonSerialize();
|
||||
|
||||
if (!$entry->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']);
|
||||
if (!$entry->hasPermission(SharingACL::FILES)) {
|
||||
unset($tmp['credential_data']['files']);
|
||||
}
|
||||
unset($tmp['credential_data']['shared_key']);
|
||||
$return[] = $tmp;
|
||||
}
|
||||
|
|
@ -150,12 +156,16 @@ class ShareService {
|
|||
$acl = $this->sharingACL->getItemACL($user_id, $item_guid);
|
||||
|
||||
// Check if the user can read the credential, probably unnecesary, but just to be sure
|
||||
if (!$acl->hasPermission(SharingACL::READ)) throw new DoesNotExistException("Item not found or wrong access level");
|
||||
if (!$acl->hasPermission(SharingACL::READ)) {
|
||||
throw new DoesNotExistException("Item not found or wrong access level");
|
||||
}
|
||||
|
||||
$tmp = $acl->jsonSerialize();
|
||||
$tmp['credential_data'] = $this->credential->getCredentialById($acl->getItemId())->jsonSerialize();
|
||||
|
||||
if (!$acl->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']);
|
||||
if (!$acl->hasPermission(SharingACL::FILES)) {
|
||||
unset($tmp['credential_data']['files']);
|
||||
}
|
||||
unset($tmp['credential_data']['shared_key']);
|
||||
|
||||
return $tmp;
|
||||
|
|
@ -170,7 +180,9 @@ class ShareService {
|
|||
*/
|
||||
public function getItemHistory($user_id, $item_guid) {
|
||||
$acl = $this->sharingACL->getItemACL($user_id, $item_guid);
|
||||
if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) return [];
|
||||
if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->revisions->getRevisions($acl->getItemId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue