mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-16 10:15:02 +00:00
controller refactoring part 24
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Domain\Sharing\Actions;
|
||||
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Sharing\Models\Share;
|
||||
|
||||
class VerifyAccessToItemWithinAction
|
||||
{
|
||||
public function __construct(
|
||||
private VerifyAccessToItemAction $verifyAccessToItem,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check user file access
|
||||
*/
|
||||
public function __invoke(
|
||||
Share $shared,
|
||||
File $file
|
||||
): void {
|
||||
// Check by parent folder permission
|
||||
if ($shared->type === 'folder') {
|
||||
($this->verifyAccessToItem)($file->folder_id, $shared);
|
||||
}
|
||||
|
||||
// Check by single file permission
|
||||
if ($shared->type === 'file') {
|
||||
if ($shared->item_id !== $file->id) {
|
||||
abort(403);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user