image silent exceptions

This commit is contained in:
Yuri Kuznetsov
2022-05-10 17:42:14 +03:00
parent 41c7cf115d
commit 58d161210d

View File

@@ -34,8 +34,8 @@ use Espo\Repositories\Attachment as AttachmentRepository;
use Espo\Core\{
Exceptions\NotFound,
Exceptions\NotFoundSilent,
Exceptions\Forbidden,
Exceptions\BadRequest,
Exceptions\ForbiddenSilent,
Exceptions\Error,
EntryPoint\EntryPoint,
Acl,
@@ -120,24 +120,24 @@ class Image implements EntryPoint
}
if (!$disableAccessCheck && !$this->acl->checkEntity($attachment)) {
throw new Forbidden();
throw new ForbiddenSilent("No access to attachment.");
}
$fileType = $attachment->get('type');
if (!in_array($fileType, $this->getAllowedFileTypeList())) {
throw new Forbidden("Not allowed file type '{$fileType}'.");
throw new ForbiddenSilent("Not allowed file type '{$fileType}'.");
}
if ($this->allowedRelatedTypeList) {
if (!in_array($attachment->get('relatedType'), $this->allowedRelatedTypeList)) {
throw new NotFound();
throw new NotFoundSilent();
}
}
if ($this->allowedFieldList) {
if (!in_array($attachment->get('field'), $this->allowedFieldList)) {
throw new NotFound();
throw new NotFoundSilent();
}
}