Skip to content

Commit

Permalink
Converts IsGranted to new attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
frostieDE committed Jul 28, 2024
1 parent 086377e commit 83ca8b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Api/ActiveDirectoryConnectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
use App\Security\UserCreator;
use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Attributes as OA;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use App\Response\ActiveDirectoryUser as ActiveDirectoryUserResponse;
use Symfony\Component\Security\Http\Attribute\IsGranted;

/**
* Endpunkte für den Active Directory Connect Client
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/MarkdownController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace App\Controller;

use League\CommonMark\MarkdownConverterInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted('ROLE_ADMIN')]
class MarkdownController extends AbstractController {
Expand Down
8 changes: 6 additions & 2 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
use DateTime;
use SchulIT\CommonBundle\Form\ConfirmType;
use SchulIT\CommonBundle\Utils\RefererHelper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand All @@ -39,6 +39,11 @@
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Contracts\Translation\TranslatorInterface;

#[IsGranted(
new Expression(
"is_granted('ROLE_ADMIN') or is_granted('ROLE_PASSWORD_MANAGER')"
)
)]
class UserController extends AbstractController {

use AttributeDataTrait;
Expand Down Expand Up @@ -107,7 +112,6 @@ private function internalDisplay(Request $request, UserTypeFilter $typeFilter, U
}

#[Route(path: '/users', name: 'users')]
#[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_PASSWORD_MANAGER')")]
public function index(Request $request, UserTypeFilter $typeFilter, UserRoleFilter $roleFilter): Response {
return $this->internalDisplay($request, $typeFilter, $roleFilter, false);
}
Expand Down

0 comments on commit 83ca8b9

Please sign in to comment.