Skip to content

Commit

Permalink
Ensure a token can only be redeemed once
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunicorn committed Nov 15, 2023
1 parent f747b67 commit 10258fe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions synapse_super_invites/resource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ async def _async_render_POST(self, request: SynapseRequest) -> Tuple[int, JsonDi
if not token:
return 404, {"error": "Token not found", "errcode": "NOT_FOUND"}

if session.scalar(select(Accepted).where(Accepted.user==my_id, Accepted.token==token)):
return 400, {"error": "Token already redeemed found", "errcode": "ALREADY_REDEEMED"}


owner = token.owner
for room in token.rooms:
await self.api.update_room_membership(sender=owner, target=my_id, room_id=room.nameOrAlias, new_membership = "invite")
Expand Down

0 comments on commit 10258fe

Please sign in to comment.