diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index b23625c4c6..22705d3bf8 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -689,6 +689,10 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status') throw new Exception('Invite does not belong to current user ('.$user->getAttribute('email').')', 401, Exception::TEAM_INVITE_MISMATCH); } + if ($membership->getAttribute('confirm') === true) { + throw new Exception('Membership already confirmed', 409); + } + $membership // Attach user to team ->setAttribute('joined', \time()) ->setAttribute('confirm', true) diff --git a/tests/e2e/Services/Teams/TeamsBaseClient.php b/tests/e2e/Services/Teams/TeamsBaseClient.php index 6173359176..31be119ca9 100644 --- a/tests/e2e/Services/Teams/TeamsBaseClient.php +++ b/tests/e2e/Services/Teams/TeamsBaseClient.php @@ -348,6 +348,17 @@ trait TeamsBaseClient $this->assertEquals(400, $response['headers']['status-code']); + $response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$membershipUid.'/status', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ]), [ + 'secret' => $secret, + 'userId' => $userUid, + ]); + + $this->assertEquals(409, $response['headers']['status-code']); + return $data; }