mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
coderabbit feedback
This commit is contained in:
@@ -59,7 +59,6 @@ use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\Assoc;
|
||||
use Utopia\Validator\Boolean;
|
||||
use Utopia\Validator\Text;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
App::post('/v1/teams')
|
||||
->desc('Create team')
|
||||
|
||||
@@ -77,9 +77,13 @@ class Role extends Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$role = DbRole::parse($value);
|
||||
$valid = $role->getRole() === Roles::ROLE_PROJECT ? !empty($role->getIdentifier()) && \in_array($role->getDimension(), $this->roles) : \in_array($role->getRole(), $this->roles);
|
||||
try {
|
||||
$role = DbRole::parse($value);
|
||||
$valid = $role->getRole() === Roles::ROLE_PROJECT ? !empty($role->getIdentifier()) && \in_array($role->getDimension(), $this->roles) : \in_array($role->getRole(), $this->roles);
|
||||
return $valid;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class User extends Document
|
||||
}
|
||||
|
||||
foreach ($this->getAttribute('memberships', []) as $node) {
|
||||
if (!isset($node['confirm']) || !$node['confirm'] || !isset($node['id']) || !isset($node['teamId'])) {
|
||||
if (!isset($node['confirm']) || !$node['confirm'] || !isset($node['$id']) || !isset($node['teamId'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class User extends Document
|
||||
$roles = \array_merge($roles, $projectRoles);
|
||||
} else {
|
||||
$roles[] = Role::team($node['teamId'])->toString(); // Add base role for the team
|
||||
$teamRoles = \array_map(fn ($role) => Role::team($node['teamId'], $role)->toString(), $node['roles'] ?? []);
|
||||
$teamRoles = \array_map(fn ($role) => Role::team($node['teamId'], $role)->toString(), $node['roles'] ?? []);
|
||||
$roles = \array_merge($roles, $teamRoles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
|
||||
class TeamsConsoleClientTest extends Scope
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user