fix api permission check for metadata and filter endpoints
This commit is contained in:
parent
06aad1df7f
commit
c53ace807c
|
@ -400,7 +400,7 @@ class REST_Filters_Controller extends REST_Controller {
|
|||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if(!isset($request['collection_id'])) {
|
||||
if ( 'edit' === $request['context'] && ! $this->filter_repository->can_read( new Entities\Filter() ) ) {
|
||||
if ( 'edit' === $request['context'] && ! $this->filter_repository->can_edit( new Entities\Filter() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -378,11 +378,26 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
* @throws \Exception
|
||||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( 'edit' === $request['context'] && ! $this->metadatum_repository->can_edit(new Entities\Metadatum()) ) {
|
||||
return false;
|
||||
|
||||
if(!isset($request['collection_id'])) {
|
||||
if ( 'edit' === $request['context'] && ! $this->metadatum_repository->can_edit( new Entities\Metadatum() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
$collection = $this->collection_repository->fetch($request['collection_id']);
|
||||
|
||||
if($collection instanceof Entities\Collection){
|
||||
if ( 'edit' === $request['context'] && ! $collection->can_read() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue