From 11861044695e5a6553e5ca2b4db8f2fd57702f7f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 17 Dec 2016 17:02:29 -0500 Subject: Add API calls to manage tags --- app/Api/Authorization/ProjectAuthorization.php | 4 ++-- app/Api/Authorization/TagAuthorization.php | 23 +++++++++++++++++++++++ app/Api/Authorization/TaskAuthorization.php | 4 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 app/Api/Authorization/TagAuthorization.php (limited to 'app/Api/Authorization') diff --git a/app/Api/Authorization/ProjectAuthorization.php b/app/Api/Authorization/ProjectAuthorization.php index 21ecf311..7dcdc445 100644 --- a/app/Api/Authorization/ProjectAuthorization.php +++ b/app/Api/Authorization/ProjectAuthorization.php @@ -23,13 +23,13 @@ class ProjectAuthorization extends Base protected function checkProjectPermission($class, $method, $project_id) { if (empty($project_id)) { - throw new AccessDeniedException('Project not found'); + throw new AccessDeniedException('Project Not Found'); } $role = $this->projectUserRoleModel->getUserRole($project_id, $this->userSession->getId()); if (! $this->apiProjectAuthorization->isAllowed($class, $method, $role)) { - throw new AccessDeniedException('Project access denied'); + throw new AccessDeniedException('Project Access Denied'); } } } diff --git a/app/Api/Authorization/TagAuthorization.php b/app/Api/Authorization/TagAuthorization.php new file mode 100644 index 00000000..247f57db --- /dev/null +++ b/app/Api/Authorization/TagAuthorization.php @@ -0,0 +1,23 @@ +userSession->isLogged()) { + $tag = $this->tagModel->getById($tag_id); + + if (! empty($tag)) { + $this->checkProjectPermission($class, $method, $tag['project_id']); + } + } + } +} diff --git a/app/Api/Authorization/TaskAuthorization.php b/app/Api/Authorization/TaskAuthorization.php index db93b76b..6e044211 100644 --- a/app/Api/Authorization/TaskAuthorization.php +++ b/app/Api/Authorization/TaskAuthorization.php @@ -10,10 +10,10 @@ namespace Kanboard\Api\Authorization; */ class TaskAuthorization extends ProjectAuthorization { - public function check($class, $method, $category_id) + public function check($class, $method, $task_id) { if ($this->userSession->isLogged()) { - $this->checkProjectPermission($class, $method, $this->taskFinderModel->getProjectId($category_id)); + $this->checkProjectPermission($class, $method, $this->taskFinderModel->getProjectId($task_id)); } } } -- cgit v1.2.3