fixes quick for accompanying cours edocument voter

This commit is contained in:
Julien Fastré 2021-09-24 13:51:43 +02:00
parent 388db459bf
commit 62f8d2c01d
2 changed files with 10 additions and 16 deletions

View File

@ -7,6 +7,7 @@ use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Psr\Log\LoggerInterface;
@ -57,30 +58,23 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
self::DELETE
];
}
protected function supports($attribute, $subject)
{
if (\in_array($attribute, $this->getRoles()) && $subject instanceof AccompanyingCourseDocument) {
if (\in_array($attribute, $this->getRoles())) {
return true;
}
//if ($subject instanceof AccompanyingPeriod && $attribute === self::CREATE) {
return true;
//}
return false;
}
protected function isGranted($attribute, $report, $user = null)
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
{
if (! $user instanceof User){
return false;
}
// TODO
// return $this->helper->userHasAccess($user, $report, $attribute);
return true;
}
public function getRolesWithoutScope()
{
return array();

View File

@ -25,7 +25,7 @@
aria-expanded="false">
{{ 'Welcome' | trans }}<br/>
<b>
{{ app.user.username }}
{{ render(controller('ChillMainBundle:UI:showNotificationUserCounter')) }}
@ -40,8 +40,8 @@
{% for menu in menus %}
{% if is_granted('ROLE_PREVIOUS_ADMIN') and menu.name == 'Logout' %}
<a class="dropdown-item list-group-item bg-dark text-white"
href="{{ path('admin_user', {'_switch_user': '_exit'}) }}">
<a class="dropdown-item list-group-item bg-dark text-white"
href="{{ path('chill_crud_admin_user_index', {'_switch_user': '_exit'}) }}">
{{ 'Exit impersonation'|trans }}
{% else %}
<a class="dropdown-item list-group-item bg-dark text-white"