Skip to content

Commit

Permalink
Merge pull request #117 from whyphi/staging
Browse files Browse the repository at this point in the history
Release: `3.0.0`
  • Loading branch information
wderocco8 authored Sep 14, 2024
2 parents d8fa1f9 + ec92db5 commit 805837f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chalicelib/services/EventsMemberService.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from chalicelib.modules.mongo import mongo_module
from chalice import NotFoundError, BadRequestError
from chalice import NotFoundError, BadRequestError, UnauthorizedError
import json
from bson import ObjectId
import datetime
Expand Down Expand Up @@ -121,7 +121,7 @@ def checkin(self, event_id: str, user: dict) -> dict:
Returns:
dict -- Dictionary containing status and message.
"""
user_id, user_email = user["id"], user["email"]
user_id, user_email, code = user["id"], user["email"], user["code"]
member = self.mongo_module.get_document_by_id("users", user_id)
if member is None:
raise NotFoundError(f"User with ID {user_id} does not exist.")
Expand All @@ -132,6 +132,9 @@ def checkin(self, event_id: str, user: dict) -> dict:
f"{self.collection_prefix}event", event_id
)

if code.lower().strip() != event["code"].lower().strip():
raise UnauthorizedError("Invalid code.")

if any(d["userId"] == user_id for d in event["usersAttended"]):
raise BadRequestError(f"{user_name} has already checked in.")

Expand Down

0 comments on commit 805837f

Please sign in to comment.