Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
ShizukuNanami | fbb8989ac1 |
|
@ -6,6 +6,7 @@ from datetime import datetime
|
|||
import pytz
|
||||
import base64
|
||||
import zlib
|
||||
import json
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Hash import SHA
|
||||
from Crypto.Signature import PKCS1_v1_5
|
||||
|
@ -349,6 +350,17 @@ class AllnetServlet:
|
|||
self.logger.info(f"Ping from {Utils.get_ip_addr(request)}")
|
||||
return b"naomi ok"
|
||||
|
||||
# access_code to userid
|
||||
def handle_acuid(self, request: Request, match: Dict) -> bytes:
|
||||
try:
|
||||
content_str = request.content.getvalue()
|
||||
content_json = json.loads(content_str)
|
||||
uid = self.data.card.get_user_id_from_card(content_json.get('access_code'))
|
||||
return str(uid).encode('utf-8')
|
||||
except (json.JSONDecodeError, KeyError, TypeError) as e:
|
||||
return str(e).encode('utf-8')
|
||||
# end
|
||||
|
||||
def billing_req_to_dict(self, data: bytes):
|
||||
"""
|
||||
Parses an billing request string into a python dictionary
|
||||
|
|
10
index.py
10
index.py
|
@ -42,6 +42,16 @@ class HttpDispatcher(resource.Resource):
|
|||
conditions=dict(method=["POST"]),
|
||||
)
|
||||
|
||||
# access_code to userid
|
||||
self.map_post.connect(
|
||||
"access_userid",
|
||||
"/accesscode.html",
|
||||
controller="allnet",
|
||||
action="handle_acuid",
|
||||
conditions=dict(method=["POST"]),
|
||||
)
|
||||
# end
|
||||
|
||||
self.map_get.connect(
|
||||
"allnet_ping",
|
||||
"/naomitest.html",
|
||||
|
|
Loading…
Reference in New Issue