add clientID
This commit is contained in:
parent
1ecfe5daab
commit
642580ccd5
@ -16,6 +16,7 @@ from database.room.models import Anonymous, Challenge, Challenges, CorrigedGener
|
||||
TmpCorrection, Waiter, MemberRead, CorrigedData, CorrectionData, Challenger
|
||||
from services.auth import get_current_user_optional
|
||||
from services.database import generate_unique_code
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
|
||||
def create_room_db(*, room: RoomCreate, user: User | None = None, username: str | None = None, db: Session):
|
||||
@ -178,7 +179,7 @@ def create_anonymous_member(username: str, room: Room, db: Session):
|
||||
return None
|
||||
reconnect_code = generate_unique_code(
|
||||
Anonymous, s=db, field_name="reconnect_code")
|
||||
anonymous = Anonymous(username=username, reconnect_code=reconnect_code)
|
||||
anonymous = Anonymous(username=username, reconnect_code=reconnect_code, clientId=uuid4())
|
||||
member_id = generate_unique_code(Member, s=db)
|
||||
member = Member(room=room, anonymous=anonymous, id_code=member_id)
|
||||
db.add(member)
|
||||
@ -787,9 +788,11 @@ def get_room(room_id, db: Session = Depends(get_session)):
|
||||
|
||||
def get_member_dep(room: Room = Depends(get_room), user: User = Depends(get_current_user_optional),
|
||||
clientId: str | None = Query(default=None), db: Session = Depends(get_session)):
|
||||
|
||||
if user is None and clientId is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="Not authenticated")
|
||||
member = None
|
||||
if user is not None:
|
||||
member = get_member_from_user(user.id, room.id, db)
|
||||
elif clientId is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user