fix(files): Don't throw an error when guests access the controller

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2023-04-19 16:39:57 +02:00
parent fd473f89e8
commit 8b31d8204f
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205
2 changed files with 9 additions and 16 deletions

View file

@ -70,28 +70,18 @@ class ApiController extends Controller {
private IPreview $previewManager;
private IUserSession $userSession;
private IConfig $config;
private Folder $userFolder;
private ?Folder $userFolder;
private UserConfig $userConfig;
private ViewConfig $viewConfig;
/**
* @param string $appName
* @param IRequest $request
* @param IUserSession $userSession
* @param TagService $tagService
* @param IPreview $previewManager
* @param IManager $shareManager
* @param IConfig $config
* @param Folder $userFolder
*/
public function __construct($appName,
public function __construct(string $appName,
IRequest $request,
IUserSession $userSession,
TagService $tagService,
IPreview $previewManager,
IManager $shareManager,
IConfig $config,
Folder $userFolder,
?Folder $userFolder,
UserConfig $userConfig,
ViewConfig $viewConfig) {
parent::__construct($appName, $request);
@ -406,7 +396,7 @@ class ApiController extends Controller {
$node = $this->userFolder->get($folderpath);
return $node->getType();
}
/**
* @NoAdminRequired
* @NoCSRFRequired

View file

@ -44,7 +44,7 @@ class TagService {
private $activityManager;
/** @var ITags|null */
private $tagger;
/** @var Folder */
/** @var Folder|null */
private $homeFolder;
/** @var EventDispatcherInterface */
private $dispatcher;
@ -53,7 +53,7 @@ class TagService {
IUserSession $userSession,
IManager $activityManager,
?ITags $tagger,
Folder $homeFolder,
?Folder $homeFolder,
EventDispatcherInterface $dispatcher
) {
$this->userSession = $userSession;
@ -77,6 +77,9 @@ class TagService {
if ($this->tagger === null) {
throw new \RuntimeException('No tagger set');
}
if ($this->homeFolder === null) {
throw new \RuntimeException('No homeFolder set');
}
$fileId = $this->homeFolder->get($path)->getId();