mirror of
https://github.com/nextcloud/passman.git
synced 2024-09-20 14:56:21 +08:00
Api endpoint logic to gather the ACL of a credential
This commit is contained in:
parent
af1c38f9c7
commit
bca3cefd0c
|
@ -59,6 +59,7 @@ return [
|
|||
['name' => 'share#getPublicCredentialData', 'url' => '/api/v2/sharing/credential/{credential_guid}/public', 'verb' => 'GET'],
|
||||
['name' => 'share#unshareCredential', 'url' => '/api/v2/sharing/credential/{item_guid}', 'verb' => 'DELETE'],
|
||||
['name' => 'share#getRevisions', 'url' => '/api/v2/sharing/credential/{item_guid}/revisions', 'verb' => 'GET'],
|
||||
['name' => 'share#getItemAcl', 'url' => '/api/v2/sharing/credential/{item_guid}/acl', 'verb' => 'GET'],
|
||||
|
||||
//Internal API
|
||||
['name' => 'internal#remind', 'url' => '/api/internal/notifications/remind/{credential_id}', 'verb' => 'POST'],
|
||||
|
|
|
@ -322,4 +322,20 @@ class ShareController extends ApiController {
|
|||
return new NotFoundResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public function getItemAcl($item_guid){
|
||||
$acl = $this->shareService->getCredentialAclList($item_guid);
|
||||
try {
|
||||
$credential = $this->credentialService->getCredentialByGUID($item_guid);
|
||||
if ($credential->getUserId() == $this->userId){
|
||||
return new JSONResponse($acl);
|
||||
}
|
||||
else{
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
}
|
||||
catch (DoesNotExistException $ex){
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -134,4 +134,14 @@ class CredentialMapper extends Mapper {
|
|||
public function upd(Credential $credential){
|
||||
$this->update($credential);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a credential by the given guid
|
||||
* @param $credential_guid
|
||||
* @return Credential
|
||||
*/
|
||||
public function getCredentialByGUID($credential_guid){
|
||||
$q = 'SELECT * FROM `*PREFIX*passman_credentials` WHERE guid = ? ';
|
||||
return $this->findEntity($q, [$credential_guid]);
|
||||
}
|
||||
}
|
|
@ -73,4 +73,8 @@ class CredentialService {
|
|||
public function getCredentialLabelById($credential_id){
|
||||
return $this->credentialMapper->getCredentialLabelById($credential_id);
|
||||
}
|
||||
|
||||
public function getCredentialByGUID($credential_guid){
|
||||
return $this->credentialMapper->getCredentialByGUID($credential_guid);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue