mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge pull request #9765 from appwrite/fix-owner-downgrade
Fix owner role downgrade
This commit is contained in:
commit
8de9b7ffb2
2 changed files with 7 additions and 8 deletions
|
|
@ -1089,7 +1089,10 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId')
|
|||
// Quick check: fetch up to 2 owners to determine if only one exists
|
||||
$ownersCount = $dbForProject->count(
|
||||
collection: 'memberships',
|
||||
queries: [Query::contains('roles', ['owner'])],
|
||||
queries: [
|
||||
Query::contains('roles', ['owner']),
|
||||
Query::equal('teamInternalId', [$team->getInternalId()])
|
||||
],
|
||||
max: 2
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class TeamsConsoleClientTest extends Scope
|
|||
$session = $data['session'] ?? '';
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$roles = ['developer'];
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid, array_merge([
|
||||
|
|
@ -97,12 +97,8 @@ class TeamsConsoleClientTest extends Scope
|
|||
'roles' => $roles
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertNotEmpty($response['body']['userId']);
|
||||
$this->assertNotEmpty($response['body']['teamId']);
|
||||
$this->assertCount(count($roles), $response['body']['roles']);
|
||||
$this->assertEquals($roles[0], $response['body']['roles'][0]);
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
$this->assertEquals('There must be at least one owner in the organization.', $response['body']['message']);
|
||||
|
||||
/**
|
||||
* Test for unknown team
|
||||
|
|
|
|||
Loading…
Reference in a new issue