mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-25 12:56:04 +08:00
Expire link shared credential after x views
This commit is contained in:
parent
e71a82218e
commit
dbbe383bf9
3 changed files with 42 additions and 1 deletions
|
|
@ -301,6 +301,16 @@ class ShareController extends ApiController {
|
||||||
public function getPublicCredentialData($credential_guid) {
|
public function getPublicCredentialData($credential_guid) {
|
||||||
//@TODO if ExpireViews --, if 0 delete
|
//@TODO if ExpireViews --, if 0 delete
|
||||||
//@TODO Check expire date
|
//@TODO Check expire date
|
||||||
|
$acl = $this->shareService->getACL(null, $credential_guid);
|
||||||
|
$views = $acl->getExpireViews();
|
||||||
|
if($views === 0){
|
||||||
|
return new NotFoundResponse();
|
||||||
|
} else {
|
||||||
|
$views--;
|
||||||
|
$acl->setExpireViews($views);
|
||||||
|
$this->shareService->updateCredentialACL($acl);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$credential = $this->shareService->getSharedItem(null, $credential_guid);
|
$credential = $this->shareService->getSharedItem(null, $credential_guid);
|
||||||
return new JSONResponse($credential);
|
return new JSONResponse($credential);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,16 @@ class SharingACLMapper extends Mapper {
|
||||||
return $this->findEntity($q, $filter);
|
return $this->findEntity($q, $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the acl for a given item guid
|
||||||
|
* @param $user_id
|
||||||
|
* @param $item_guid
|
||||||
|
* @return SharingACL
|
||||||
|
*/
|
||||||
|
public function updateCredentialACL(SharingACL $sharingACL) {
|
||||||
|
return $this->update($sharingACL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the currently accepted share requests from the given user for the given vault guid
|
* Gets the currently accepted share requests from the given user for the given vault guid
|
||||||
* @param $user_id
|
* @param $user_id
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,12 @@ class ShareService {
|
||||||
return $this->shareRequest->getUserPendingRequests($user_id);
|
return $this->shareRequest->getUserPendingRequests($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shared credentials from a user
|
||||||
|
* @param $user_id
|
||||||
|
* @param $vault_guid
|
||||||
|
* @return \OCA\Passman\Db\SharingACL[]
|
||||||
|
*/
|
||||||
public function getSharedItems($user_id, $vault_guid){
|
public function getSharedItems($user_id, $vault_guid){
|
||||||
$entries = $this->sharingACL->getVaultEntries($user_id, $vault_guid);
|
$entries = $this->sharingACL->getVaultEntries($user_id, $vault_guid);
|
||||||
|
|
||||||
|
|
@ -125,6 +131,16 @@ class ShareService {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the acl for a given item guid
|
||||||
|
* @param $user_id
|
||||||
|
* @param $item_guid
|
||||||
|
* @return SharingACL
|
||||||
|
*/
|
||||||
|
public function getACL($user_id, $item_guid){
|
||||||
|
return $this->sharingACL->getItemACL($user_id, $item_guid);
|
||||||
|
}
|
||||||
|
|
||||||
public function getSharedItem($user_id, $item_guid){
|
public function getSharedItem($user_id, $item_guid){
|
||||||
$acl = $this->sharingACL->getItemACL($user_id, $item_guid);
|
$acl = $this->sharingACL->getItemACL($user_id, $item_guid);
|
||||||
|
|
||||||
|
|
@ -219,7 +235,7 @@ class ShareService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get pending share requests by guid
|
* Delete ACL
|
||||||
*
|
*
|
||||||
* @param ShareRequest $request
|
* @param ShareRequest $request
|
||||||
* @return \OCA\Passman\Db\ShareRequest[]
|
* @return \OCA\Passman\Db\ShareRequest[]
|
||||||
|
|
@ -227,4 +243,9 @@ class ShareService {
|
||||||
public function deleteShareACL(SharingACL $ACL) {
|
public function deleteShareACL(SharingACL $ACL) {
|
||||||
return $this->sharingACL->deleteShareACL($ACL);
|
return $this->sharingACL->deleteShareACL($ACL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function updateCredentialACL(SharingACL $sharingACL){
|
||||||
|
return $this->sharingACL->updateCredentialACL($sharingACL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue