improve permission handling for quick entry controller (#3081)
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
namespace App\EventSubscriber;
|
||||
|
||||
use App\Event\ConfigureMainMenuEvent;
|
||||
use App\Timesheet\TrackingModeService;
|
||||
use App\Twig\IconExtension;
|
||||
use App\Utils\MenuItemModel;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
@@ -22,12 +21,10 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
final class MenuSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $security;
|
||||
private $trackingModeService;
|
||||
|
||||
public function __construct(AuthorizationCheckerInterface $security, TrackingModeService $trackingModeService)
|
||||
public function __construct(AuthorizationCheckerInterface $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->trackingModeService = $trackingModeService;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
@@ -55,13 +52,10 @@ final class MenuSubscriber implements EventSubscriberInterface
|
||||
$timesheets->setChildRoutes(['timesheet_export', 'timesheet_edit', 'timesheet_create', 'timesheet_multi_update']);
|
||||
$menu->addItem($timesheets);
|
||||
|
||||
if ($auth->isGranted('weekly_own_timesheet') && $auth->isGranted('edit_own_timesheet')) {
|
||||
$mode = $this->trackingModeService->getActiveMode();
|
||||
if ($mode->canEditDuration() || $mode->canEditEnd()) {
|
||||
$menu->addItem(
|
||||
new MenuItemModel('quick_entry', 'quick_entry.title', 'quick_entry', [], $icons->icon('weekly-times'))
|
||||
);
|
||||
}
|
||||
if ($auth->isGranted('quick-entry')) {
|
||||
$menu->addItem(
|
||||
new MenuItemModel('quick_entry', 'quick_entry.title', 'quick_entry', [], $icons->icon('weekly-times'))
|
||||
);
|
||||
}
|
||||
|
||||
$menu->addItem(
|
||||
|
||||
Reference in New Issue
Block a user