This commit is contained in:
Lilian 2023-02-28 12:20:40 +01:00 committed by Kilton937342
parent fff0618d27
commit 3952522e78
2 changed files with 4 additions and 2 deletions

View File

@ -37,6 +37,8 @@ def create_room_db(*, room: RoomCreate, user: User | None = None, username: str
# member = Member(anonymous=anonymous, room=room_obj,
# is_admin=True, id_code=member_id)
member = create_anonymous_member(username, room_obj, db)
if member is None:
raise ValueError('Nom d\'utilisateur invalide (4 - 15 caractères)')
member.is_admin = True
db.add(member)
@ -168,7 +170,7 @@ def disconnect_member(member: Member, db: Session):
def validate_username(username: str, room: Room, db: Session = Depends(get_session)):
username = username.strip()
if 4 < len(username) > 15:
if not (4 <= len(username) <= 15):
return None
members = select(Member.anonymous_id).where(
Member.room_id == room.id, Member.anonymous_id != None)

View File

@ -170,7 +170,7 @@ class RoomConsumer(Consumer):
elif username is not None:
username = username.strip()
if 4 > len(username) > 15:
if not (4 <= len(username) <= 15):
await self.send_error("Nom invalide (4-15 caractères)")
return