diff --git a/composer.lock b/composer.lock index fd6fba9..8eef362 100644 --- a/composer.lock +++ b/composer.lock @@ -79,16 +79,16 @@ }, { "name": "bnine/filesbundle", - "version": "v1.0.31", + "version": "v1.0.39", "source": { "type": "git", "url": "https://github.com/afornerot/bNine-FilesBundle.git", - "reference": "b9a1cf8d2ec53abf34309ae721f9136a8eca9b66" + "reference": "9fab2530ec5528ce449351886ca6c503acee4b2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/afornerot/bNine-FilesBundle/zipball/b9a1cf8d2ec53abf34309ae721f9136a8eca9b66", - "reference": "b9a1cf8d2ec53abf34309ae721f9136a8eca9b66", + "url": "https://api.github.com/repos/afornerot/bNine-FilesBundle/zipball/9fab2530ec5528ce449351886ca6c503acee4b2c", + "reference": "9fab2530ec5528ce449351886ca6c503acee4b2c", "shasum": "" }, "require": { @@ -109,10 +109,10 @@ ], "description": "Symfony bundle for file-browser", "support": { - "source": "https://github.com/afornerot/bNine-FilesBundle/tree/v1.0.31", + "source": "https://github.com/afornerot/bNine-FilesBundle/tree/v1.0.39", "issues": "https://github.com/afornerot/bNine-FilesBundle/issues" }, - "time": "2025-08-01T17:06:06+00:00" + "time": "2025-08-01T18:40:55+00:00" }, { "name": "brick/math", @@ -499,16 +499,16 @@ }, { "name": "doctrine/doctrine-bundle", - "version": "2.15.0", + "version": "2.15.1", "source": { "type": "git", "url": "https://github.com/doctrine/DoctrineBundle.git", - "reference": "d88294521a1bca943240adca65fa19ca8a7288c6" + "reference": "5a305c5e776f9d3eb87f5b94d40d50aff439211d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d88294521a1bca943240adca65fa19ca8a7288c6", - "reference": "d88294521a1bca943240adca65fa19ca8a7288c6", + "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/5a305c5e776f9d3eb87f5b94d40d50aff439211d", + "reference": "5a305c5e776f9d3eb87f5b94d40d50aff439211d", "shasum": "" }, "require": { @@ -601,7 +601,7 @@ ], "support": { "issues": "https://github.com/doctrine/DoctrineBundle/issues", - "source": "https://github.com/doctrine/DoctrineBundle/tree/2.15.0" + "source": "https://github.com/doctrine/DoctrineBundle/tree/2.15.1" }, "funding": [ { @@ -617,7 +617,7 @@ "type": "tidelift" } ], - "time": "2025-06-16T19:53:58+00:00" + "time": "2025-07-30T15:48:28+00:00" }, { "name": "doctrine/doctrine-migrations-bundle", diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index ca5868f..e145340 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -3,6 +3,8 @@ twig: form_themes: ['bootstrap_5_layout.html.twig'] globals: appName: "%appName%" + paths: + '%kernel.project_dir%/vendor/bnine/filesbundle/templates': BnineFilesBundle when@test: twig: strict_variables: true diff --git a/src/Entity/User.php b/src/Entity/User.php index db3f4d1..1cbee03 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -105,6 +105,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + public function hasRole(string $role): bool + { + return in_array($role, $this->getRoles()); + } + /** * @see PasswordAuthenticatedUserInterface */ diff --git a/src/Security/FileVoter.php b/src/Security/FileVoter.php new file mode 100644 index 0000000..b75af85 --- /dev/null +++ b/src/Security/FileVoter.php @@ -0,0 +1,50 @@ +projectRepository = $projectRepository; + } + + protected function canView(string $domain, $id, TokenInterface $token): bool + { + $user = $token->getUser(); + if (!$user instanceof User) { + return false; + } + + return true; + } + + protected function canEdit(string $domain, $id, TokenInterface $token): bool + { + $user = $token->getUser(); + if (!$user instanceof User) { + return false; + } + if ($user->hasRole('ROLE_ADMIN')) { + return true; + } + + switch ($domain) { + case 'project': + $project = $this->projectRepository->find($id); + if ($project && $project->getUsers()->contains($user)) { + return true; + } + break; + } + + return false; + } +}