Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
13 changes: 10 additions & 3 deletions chalicelib/services/EventsRushService.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import datetime
from chalicelib.s3 import s3
from chalicelib.utils import get_prev_image_version
from typing import Optional

class EventsRushService:
class BSONEncoder(json.JSONEncoder):
Expand Down Expand Up @@ -201,7 +202,7 @@ def get_rush_event(self, event_id: str, data: dict):
)

if hide_attendees:
event.pop("attendeesId", None)
event.pop("attendees", None)

if hide_code:
event.pop("code")
Expand All @@ -215,7 +216,13 @@ def checkin_rush(self, event_id: str, user_data: dict):
f"{self.collection_prefix}rush-event", event_id
)

code = user_data["code"]
raw_user_code: str = user_data.get("code", "")
user_code = raw_user_code.lower().strip()

raw_event_code: Optional[str] = event.get("code", None)
if raw_event_code:
event_code = raw_event_code.lower().strip()

user_data.pop("code")

# Parse the timestamp string to a datetime object
Expand All @@ -224,7 +231,7 @@ def checkin_rush(self, event_id: str, user_data: dict):
if datetime.datetime.now() > deadline:
raise UnauthorizedError("Event deadline has passed.")

if code != event["code"]:
if user_code != event_code:
raise UnauthorizedError("Invalid code.")

if any(d["email"] == user_data["email"] for d in event["attendees"]):
Expand Down
Loading