增加登录返回的username参数
This commit is contained in:
parent
2d8edb3dce
commit
4724ca3bcc
5
CS3.1.py
5
CS3.1.py
@ -7,7 +7,6 @@ import base64
|
|||||||
import secrets
|
import secrets
|
||||||
import time
|
import time
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
socket_server = socket.socket()
|
socket_server = socket.socket()
|
||||||
socket_server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
socket_server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
|
||||||
@ -133,8 +132,8 @@ def handle_socket_message(data, addr, conn):
|
|||||||
active_users[addr[0]] = data['username']
|
active_users[addr[0]] = data['username']
|
||||||
tk = base64.b64encode(data['username'].encode('utf-8'))
|
tk = base64.b64encode(data['username'].encode('utf-8'))
|
||||||
chat_connections.append(conn)
|
chat_connections.append(conn)
|
||||||
return {"type": "login_1", "status": "success", "message": "Login successful", "token": generate_token(data['username'])}
|
return {"type": "login_1", "status": "success", "message": "Login successful", "token": generate_token(data['username']), "username": data['username']}
|
||||||
return {"type": "login_0", "status": "error", "message": "Invalid credentials"}
|
return {"type": "login_0", "status": "error", "message": "Invalid credentials", "username": data['username']}
|
||||||
elif action == 'chat':
|
elif action == 'chat':
|
||||||
if addr[0] in active_users:
|
if addr[0] in active_users:
|
||||||
message = {
|
message = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user