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

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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