fix: console

This commit is contained in:
loks0n
2024-11-05 17:59:14 +01:00
parent 71879236b8
commit 9d1f366161
2 changed files with 12 additions and 6 deletions
+10 -4
View File
@@ -728,15 +728,23 @@ App::get('/v1/teams/:teamId/memberships')
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->inject('response')
->inject('project')
->inject('dbForConsole')
->inject('dbForProject')
->action(function (string $teamId, array $queries, string $search, Response $response, Document $project, Database $dbForProject) {
->action(function (string $teamId, array $queries, string $search, Response $response, Document $project, Database $dbForConsole, Database $dbForProject) {
$team = $dbForProject->getDocument('teams', $teamId);
if ($team->isEmpty()) {
throw new Exception(Exception::TEAM_NOT_FOUND);
}
$project = $dbForConsole->getDocument('projects', $project->getId());
if ($project->isEmpty()) {
throw new Exception(Exception::PROJECT_NOT_FOUND);
}
$sensitiveAttributes = $project->getAttribute('auths', [])['teamsSensitiveAttributes'] ?? true;
try {
$queries = Query::parseQueries($queries);
} catch (QueryException $e) {
@@ -791,8 +799,6 @@ App::get('/v1/teams/:teamId/memberships')
$memberships = array_filter($memberships, fn (Document $membership) => !empty($membership->getAttribute('userId')));
$sensitiveAttributes = $project->getAttribute('auths', [])['teamsSensitiveAttributes'] ?? true;
$memberships = array_map(function ($membership) use ($dbForProject, $team, $sensitiveAttributes) {
$user = $dbForProject->getDocument('users', $membership->getAttribute('userId'));
$membership->setAttribute('teamName', $team->getAttribute('name'));
+2 -2
View File
@@ -140,7 +140,7 @@ trait TeamsBaseClient
'x-appwrite-project' => 'console',
'x-appwrite-key' => $this->getProject()['apiKey'],
]), [
'enabled' => 'false',
'enabled' => false,
]);
/**
@@ -156,7 +156,7 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['memberships'][0]['$id']);
// Assert that sensitive fields are not present
$this->assertArrayNotHasKey('userName', $response['body']['memberships'][0]);
$this->assertArrayNotHasKey('userName', $response['body']['memberships'][0], 'userName was present: ' . $response['body']['memberships'][0]['userName']);
$this->assertArrayNotHasKey('userEmail', $response['body']['memberships'][0]);
$this->assertArrayNotHasKey('mfa', $response['body']['memberships'][0]);