Browse Source

Minor cleanups

master
mid-kid 4 weeks ago
parent
commit
028251809b
  1. 21
      auth/server.py

21
auth/server.py

@ -7,15 +7,8 @@ from base64 import b64encode
from os.path import getmtime from os.path import getmtime
import json import json
userdata = { userdata = {}
"9a10d47934294527b3a0a32ab41d207e": { g_connections = {}
"name": "test1"
},
"4ad1f41992193cb986741243f14d81e8": {
"name": "test2"
}
}
connections = {}
class HTTPRequestHandler(BaseHTTPRequestHandler): class HTTPRequestHandler(BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1" protocol_version = "HTTP/1.1"
@ -141,7 +134,7 @@ class HTTPRequestHandler(BaseHTTPRequestHandler):
token, profileId = params["sessionId"][0].split(":")[1:] token, profileId = params["sessionId"][0].split(":")[1:]
serverId = params["serverId"][0] serverId = params["serverId"][0]
connections[serverId] = profileId g_connections[serverId] = profileId
if True: if True:
self.send_ok(b"OK") self.send_ok(b"OK")
@ -155,7 +148,7 @@ class HTTPRequestHandler(BaseHTTPRequestHandler):
profileId = data["selectedProfile"] profileId = data["selectedProfile"]
serverId = data["serverId"] serverId = data["serverId"]
connections[serverId] = profileId g_connections[serverId] = profileId
if True: if True:
self.send_response(HTTPStatus.NO_CONTENT) self.send_response(HTTPStatus.NO_CONTENT)
@ -171,7 +164,7 @@ class HTTPRequestHandler(BaseHTTPRequestHandler):
user = params["user"][0] user = params["user"][0]
serverId = params["serverId"][0] serverId = params["serverId"][0]
if not serverId in connections: if not serverId in g_connections:
self.send_ok(b"NO") self.send_ok(b"NO")
self.send_ok(b"YES") self.send_ok(b"YES")
@ -180,11 +173,11 @@ class HTTPRequestHandler(BaseHTTPRequestHandler):
serverId = params["serverId"][0] serverId = params["serverId"][0]
user = params["username"][0] user = params["username"][0]
if not serverId in connections: if not serverId in g_connections:
self.send_response(HTTPStatus.NO_CONTENT) self.send_response(HTTPStatus.NO_CONTENT)
self.end_headers() self.end_headers()
profileId = connections[serverId] profileId = g_connections[serverId]
data = self.get_profile(profileId) data = self.get_profile(profileId)
if data is None: if data is None:

Loading…
Cancel
Save