allow TEAMLEAD to see user times (#13) (#14)

This commit is contained in:
Kevin Papst
2018-01-05 10:02:05 +01:00
committed by GitHub
parent 80d0dc2369
commit fab663dae1
3 changed files with 22 additions and 10 deletions

View File

@@ -11,6 +11,7 @@
namespace TimesheetBundle\Controller\Admin;
use Pagerfanta\Pagerfanta;
use TimesheetBundle\Entity\Timesheet;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
@@ -21,8 +22,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/**
* Controller used for manage timesheet entries in the admin part of the site.
*
* @Route("/admin/timesheet")
* @Security("has_role('ROLE_ADMIN')")
* @Route("/team/timesheet")
* @Security("has_role('ROLE_TEAMLEAD')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/

View File

@@ -52,16 +52,23 @@ class Menu
$menu = $event->getAdminMenu();
$auth = $event->getAuth();
$isLoggedIn = $auth->isGranted('IS_AUTHENTICATED_FULLY');
$isAdmin = $isLoggedIn && $auth->isGranted('ROLE_ADMIN');
if (!$auth->isGranted('IS_AUTHENTICATED_FULLY')) {
return;
}
if (!$isAdmin) {
if (!$auth->isGranted('ROLE_TEAMLEAD')) {
return;
}
$menu->addChild(
new MenuItemModel('timesheet_admin', 'menu.admin_timesheet', 'admin_timesheet', [], 'fa fa-clock-o')
)->addChild(
);
if (!$auth->isGranted('ROLE_ADMIN')) {
return;
}
$menu->addChild(
new MenuItemModel('customer_admin', 'menu.admin_customer', 'admin_customer', [], 'fa fa-users')
)->addChild(
new MenuItemModel('project_admin', 'menu.admin_project', 'admin_project', [], 'fa fa-book')