diff --git a/app/init/resources.php b/app/init/resources.php index 946a977aa4..4d1e0444c5 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -234,12 +234,12 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons Auth::$unique = $session['id'] ?? ''; Auth::$secret = $session['secret'] ?? ''; - if ($mode === APP_MODE_ADMIN) { - $user = $dbForPlatform->getDocument('users', Auth::$unique); - } else { - if ($project->isEmpty()) { - $user = new Document([]); - } else { + $user = new Document([]); + + if (!empty(Auth::$unique)) { + if ($mode === APP_MODE_ADMIN) { + $user = $dbForPlatform->getDocument('users', Auth::$unique); + } elseif (!$project->isEmpty()) { if ($project->getId() === 'console') { $user = $dbForPlatform->getDocument('users', Auth::$unique); } else { @@ -849,11 +849,20 @@ App::setResource('team', function (Document $project, Database $dbForPlatform, A $teamInternalId = $p->getAttribute('teamInternalId', ''); } elseif ($path === '/v1/projects') { $teamId = $request->getParam('teamId', ''); + + if (empty($teamId)) { + return new Document([]); + } + $team = Authorization::skip(fn () => $dbForPlatform->getDocument('teams', $teamId)); return $team; } } + if (empty($teamInternalId)) { + return new Document([]); + } + $team = Authorization::skip(function () use ($dbForPlatform, $teamInternalId) { return $dbForPlatform->findOne('teams', [ Query::equal('$sequence', [$teamInternalId]),