Remove dark magic middleware and check permission in services
This commit is contained in:
@@ -24,8 +24,7 @@
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCP\ILogger;
|
||||
use OCP\IL10N;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
|
||||
|
||||
@@ -34,19 +33,22 @@ class LabelService {
|
||||
private $labelMapper;
|
||||
private $logger;
|
||||
|
||||
public function __construct(ILogger $logger,
|
||||
IL10N $l10n,
|
||||
LabelMapper $labelMapper) {
|
||||
public function __construct(
|
||||
LabelMapper $labelMapper,
|
||||
PermissionService $permissionService
|
||||
) {
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->logger = $logger;
|
||||
$this->permissionService = $permissionService;
|
||||
}
|
||||
|
||||
public function find($labelId) {
|
||||
$this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
|
||||
$label = $this->labelMapper->find($labelId);
|
||||
return $label;
|
||||
}
|
||||
|
||||
public function create($title, $color, $boardId) {
|
||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
||||
$label = new Label();
|
||||
$label->setTitle($title);
|
||||
$label->setColor($color);
|
||||
@@ -55,10 +57,12 @@ class LabelService {
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
||||
return $this->labelMapper->delete($this->find($id));
|
||||
}
|
||||
|
||||
public function update($id, $title, $color) {
|
||||
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
||||
$label = $this->find($id);
|
||||
$label->setTitle($title);
|
||||
$label->setColor($color);
|
||||
|
||||
Reference in New Issue
Block a user