mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Refactor SavedExportVoter to improve export permission check
Revised the permission logic in `canUserGenerate` to enhance clarity and maintainability. Replaced nested condition with early return and updated the export permission check to use `isGrantedForElement`.
This commit is contained in:
@@ -60,7 +60,12 @@ class SavedExportVoter extends Voter
|
||||
|
||||
private function canUserGenerate(User $user, SavedExport $savedExport): bool
|
||||
{
|
||||
return ($savedExport->getUser() === $user || $savedExport->isSharedWithUser($user))
|
||||
&& $this->security->isGranted(ChillExportVoter::EXPORT, $this->exportManager->getExport($savedExport->getExportAlias()));
|
||||
if (!($savedExport->getUser() === $user || $savedExport->isSharedWithUser($user))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$export = $this->exportManager->getExport($savedExport->getExportAlias());
|
||||
|
||||
return $this->exportManager->isGrantedForElement($export);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user