mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-08-12 04:07:00 -05:00
Merge pull request 'chimedb update to match SDGB 1.55' (#246) from Keeboy/artemis:develop into develop
Reviewed-on: https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/246
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import secrets
|
||||
import string
|
||||
from enum import Enum
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
|
||||
@@ -69,10 +71,15 @@ class ChimeServlet:
|
||||
async def handle_qr_alive(self, request: Request):
|
||||
return PlainTextResponse("alive")
|
||||
|
||||
def _generate_token(self) -> str:
|
||||
alphabet = string.ascii_letters + string.digits
|
||||
return ''.join(secrets.choice(alphabet) for _ in range(20))
|
||||
|
||||
async def handle_qr_lookup(self, request: Request) -> bytes:
|
||||
req = json.loads(await request.body())
|
||||
access_code = req["qrCode"][-20:]
|
||||
timestamp = req["timestamp"]
|
||||
token = self._generate_token()
|
||||
|
||||
try:
|
||||
userId = await self._lookup(access_code)
|
||||
@@ -80,7 +87,8 @@ class ChimeServlet:
|
||||
"userID": userId,
|
||||
"errorID": 0,
|
||||
"timestamp": timestamp,
|
||||
"key": self._hash_key(userId, timestamp)
|
||||
"key": self._hash_key(userId, timestamp),
|
||||
"token": token
|
||||
})
|
||||
except Exception as e:
|
||||
|
||||
@@ -90,7 +98,8 @@ class ChimeServlet:
|
||||
"userID": -1,
|
||||
"errorID": ChimeDBStatus.DB_ACCESS_FAIL,
|
||||
"timestamp": timestamp,
|
||||
"key": self._hash_key(-1, timestamp)
|
||||
"key": self._hash_key(-1, timestamp),
|
||||
"token": token
|
||||
})
|
||||
|
||||
return PlainTextResponse(data)
|
||||
|
||||
Reference in New Issue
Block a user