Room password auth

This commit is contained in:
BarsTiger
2023-07-25 17:25:26 +03:00
parent ebbcf83cec
commit 333cc8ddf2
2 changed files with 8 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ class Connection(object):
ws: WebSocket ws: WebSocket
username: str username: str
public_key: str public_key: str
password: str
async def send_webmessage(self, obj: webmessages_union): async def send_webmessage(self, obj: webmessages_union):
""" """

View File

@@ -46,7 +46,8 @@ class Room(object):
connection = Connection( connection = Connection(
username=connection_message.username, username=connection_message.username,
ws=ws, ws=ws,
public_key=connection_message.public_key public_key=connection_message.public_key,
password=connection_message.password
) )
if connection_message.username in self.connections.keys(): if connection_message.username in self.connections.keys():
@@ -61,9 +62,12 @@ class Room(object):
connected_users=dict( connected_users=dict(
map( map(
lambda i, j: (i, j), lambda i, j: (i, j),
list(self.connections.keys()), [_username for _username in list(self.connections.keys())
if self.connections[_username].password ==
connection_message.password],
[_connection.public_key for _connection [_connection.public_key for _connection
in self.connections.values()] in self.connections.values() if _connection.password ==
connection_message.password]
) )
) )
)) ))