Issue #2950127 by owenbush, Yogesh Pawar, msankhala, Wim Leers, vaplas: Add helpful reason for 'update' and 'delete' access not being allowed to FileAccessControlHandler
parent
bdf6c01cb1
commit
ec8b4f8c48
|
|
@ -64,11 +64,11 @@ class FileAccessControlHandler extends EntityAccessControlHandler {
|
||||||
if ($operation == 'delete' || $operation == 'update') {
|
if ($operation == 'delete' || $operation == 'update') {
|
||||||
$account = $this->prepareUser($account);
|
$account = $this->prepareUser($account);
|
||||||
$file_uid = $entity->get('uid')->getValue();
|
$file_uid = $entity->get('uid')->getValue();
|
||||||
// Only the file owner can delete and update the file entity.
|
// Only the file owner can update or delete the file entity.
|
||||||
if ($account->id() == $file_uid[0]['target_id']) {
|
if ($account->id() == $file_uid[0]['target_id']) {
|
||||||
return AccessResult::allowed();
|
return AccessResult::allowed();
|
||||||
}
|
}
|
||||||
return AccessResult::forbidden();
|
return AccessResult::forbidden('Only the file owner can update or delete the file entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// No opinion.
|
// No opinion.
|
||||||
|
|
|
||||||
|
|
@ -224,8 +224,8 @@ abstract class FileResourceTestBase extends EntityResourceTestBase {
|
||||||
if ($method === 'GET') {
|
if ($method === 'GET') {
|
||||||
return "The 'access content' permission is required.";
|
return "The 'access content' permission is required.";
|
||||||
}
|
}
|
||||||
if ($method === 'PATCH') {
|
if ($method === 'PATCH' || $method === 'DELETE') {
|
||||||
return 'You are not authorized to update this file entity.';
|
return 'Only the file owner can update or delete the file entity.';
|
||||||
}
|
}
|
||||||
return parent::getExpectedUnauthorizedAccessMessage($method);
|
return parent::getExpectedUnauthorizedAccessMessage($method);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue