Merge pull request #2594 from Malte2036/fix-2593-duplicate-membership-verification

fix: check whether the membershipId has been confirmed to avoid recon…
This commit is contained in:
Torsten Dittmann
2022-03-03 14:40:26 +01:00
committed by GitHub
2 changed files with 15 additions and 0 deletions
+4
View File
@@ -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)
@@ -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;
}