blob: 704491b7b6c4602cae97bba73303d48f9eb2d9fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
namespace Kanboard\Middleware;
use Kanboard\Core\Controller\AccessForbiddenException;
use Kanboard\Core\Controller\BaseMiddleware;
/**
* Class ProjectAuthorizationMiddleware
*
* @package Kanboard\Middleware
* @author Frederic Guillot
*/
class ProjectAuthorizationMiddleware extends BaseMiddleware
{
/**
* Execute middleware
*/
public function execute()
{
$project_id = $this->request->getIntegerParam('project_id');
$task_id = $this->request->getIntegerParam('task_id');
if ($task_id > 0 && $project_id === 0) {
$project_id = $this->taskFinderModel->getProjectId($task_id);
}
if ($project_id > 0 && ! $this->helper->user->hasProjectAccess($this->router->getController(), $this->router->getAction(), $project_id)) {
throw new AccessForbiddenException();
}
$this->next();
}
}
|