add type hints
This commit is contained in:
parent
42c8378833
commit
b3fbf79290
14 changed files with 453 additions and 191 deletions
|
|
@ -3,6 +3,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from bumper.db import revoke_expired_oauths, revoke_expired_tokens
|
from bumper.db import revoke_expired_oauths, revoke_expired_tokens
|
||||||
from bumper.mqtt.helper_bot import HelperBot
|
from bumper.mqtt.helper_bot import HelperBot
|
||||||
|
|
@ -12,7 +13,7 @@ from bumper.web.server import WebServer, WebserverBinding
|
||||||
from bumper.xmppserver import XMPPServer
|
from bumper.xmppserver import XMPPServer
|
||||||
|
|
||||||
|
|
||||||
def strtobool(strbool):
|
def strtobool(strbool: str | bool | None) -> bool:
|
||||||
if str(strbool).lower() in ["true", "1", "t", "y", "on", "yes"]:
|
if str(strbool).lower() in ["true", "1", "t", "y", "on", "yes"]:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
@ -64,12 +65,12 @@ web_server_https_port = os.environ.get("WEB_SERVER_HTTPS_PORT") or 443
|
||||||
mqtt_listen_port = 8883
|
mqtt_listen_port = 8883
|
||||||
xmpp_listen_port = 5223
|
xmpp_listen_port = 5223
|
||||||
web_server_bindings = [
|
web_server_bindings = [
|
||||||
WebserverBinding(bumper_listen, web_server_https_port, True),
|
WebserverBinding(bumper_listen, int(web_server_https_port), True),
|
||||||
WebserverBinding(bumper_listen, 8007, False),
|
WebserverBinding(bumper_listen, 8007, False),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def start():
|
async def start() -> None:
|
||||||
try:
|
try:
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
except:
|
except:
|
||||||
|
|
@ -132,12 +133,12 @@ async def start():
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
async def maintenance():
|
async def maintenance() -> None:
|
||||||
revoke_expired_tokens()
|
revoke_expired_tokens()
|
||||||
revoke_expired_oauths()
|
revoke_expired_oauths()
|
||||||
|
|
||||||
|
|
||||||
async def shutdown():
|
async def shutdown() -> None:
|
||||||
try:
|
try:
|
||||||
bumperlog.info("Shutting down")
|
bumperlog.info("Shutting down")
|
||||||
global shutting_down
|
global shutting_down
|
||||||
|
|
@ -159,7 +160,7 @@ async def shutdown():
|
||||||
bumperlog.info("Coroutine canceled")
|
bumperlog.info("Coroutine canceled")
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv: None | list[str] = None) -> None:
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
global bumper_debug
|
global bumper_debug
|
||||||
|
|
|
||||||
98
bumper/db.py
98
bumper/db.py
|
|
@ -1,7 +1,9 @@
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from tinydb import Query, TinyDB
|
from tinydb import Query, TinyDB
|
||||||
|
from tinydb.table import Document
|
||||||
|
|
||||||
import bumper
|
import bumper
|
||||||
from bumper.models import BumperUser, OAuth, VacBotClient, VacBotDevice
|
from bumper.models import BumperUser, OAuth, VacBotClient, VacBotDevice
|
||||||
|
|
@ -11,11 +13,11 @@ from .util import get_logger
|
||||||
bumperlog = get_logger("bumper")
|
bumperlog = get_logger("bumper")
|
||||||
|
|
||||||
|
|
||||||
def db_file():
|
def db_file() -> str:
|
||||||
return os.environ.get("DB_FILE") or os_db_path()
|
return os.environ.get("DB_FILE") or os_db_path()
|
||||||
|
|
||||||
|
|
||||||
def os_db_path(): # createdir=True):
|
def os_db_path() -> str: # createdir=True):
|
||||||
return os.path.join(bumper.data_dir, "bumper.db")
|
return os.path.join(bumper.data_dir, "bumper.db")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -33,7 +35,7 @@ def db_get() -> TinyDB:
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
||||||
def user_add(userid):
|
def user_add(userid: str) -> None:
|
||||||
newuser = BumperUser()
|
newuser = BumperUser()
|
||||||
newuser.userid = userid
|
newuser.userid = userid
|
||||||
|
|
||||||
|
|
@ -43,19 +45,19 @@ def user_add(userid):
|
||||||
user_full_upsert(newuser.asdict())
|
user_full_upsert(newuser.asdict())
|
||||||
|
|
||||||
|
|
||||||
def user_get(userid):
|
def user_get(userid: str) -> None | Document:
|
||||||
users = db_get().table("users")
|
users = db_get().table("users")
|
||||||
User = Query()
|
User = Query()
|
||||||
return users.get(User.userid == userid)
|
return users.get(User.userid == userid)
|
||||||
|
|
||||||
|
|
||||||
def user_by_deviceid(deviceid: str):
|
def user_by_deviceid(deviceid: str) -> None | Document:
|
||||||
users = db_get().table("users")
|
users = db_get().table("users")
|
||||||
User = Query()
|
User = Query()
|
||||||
return users.get(User.devices.any([deviceid]))
|
return users.get(User.devices.any([deviceid]))
|
||||||
|
|
||||||
|
|
||||||
def user_full_upsert(user):
|
def user_full_upsert(user: dict[str, Any]) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
users = opendb.table("users")
|
users = opendb.table("users")
|
||||||
|
|
@ -63,69 +65,73 @@ def user_full_upsert(user):
|
||||||
users.upsert(user, User.did == user["userid"])
|
users.upsert(user, User.did == user["userid"])
|
||||||
|
|
||||||
|
|
||||||
def user_add_device(userid, devid):
|
def user_add_device(userid: str, devid: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
users = opendb.table("users")
|
users = opendb.table("users")
|
||||||
User = Query()
|
User = Query()
|
||||||
user = users.get(User.userid == userid)
|
user = users.get(User.userid == userid)
|
||||||
userdevices = list(user["devices"])
|
if user:
|
||||||
if not devid in userdevices:
|
userdevices = list(user["devices"])
|
||||||
userdevices.append(devid)
|
if not devid in userdevices:
|
||||||
|
userdevices.append(devid)
|
||||||
|
|
||||||
users.upsert({"devices": userdevices}, User.userid == userid)
|
users.upsert({"devices": userdevices}, User.userid == userid)
|
||||||
|
|
||||||
|
|
||||||
def user_remove_device(userid, devid):
|
def user_remove_device(userid: str, devid: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
users = opendb.table("users")
|
users = opendb.table("users")
|
||||||
User = Query()
|
User = Query()
|
||||||
user = users.get(User.userid == userid)
|
user = users.get(User.userid == userid)
|
||||||
userdevices = list(user["devices"])
|
if user:
|
||||||
if devid in userdevices:
|
userdevices = list(user["devices"])
|
||||||
userdevices.remove(devid)
|
if devid in userdevices:
|
||||||
|
userdevices.remove(devid)
|
||||||
|
|
||||||
users.upsert({"devices": userdevices}, User.userid == userid)
|
users.upsert({"devices": userdevices}, User.userid == userid)
|
||||||
|
|
||||||
|
|
||||||
def user_add_bot(userid, did):
|
def user_add_bot(userid: str, did: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
users = opendb.table("users")
|
users = opendb.table("users")
|
||||||
User = Query()
|
User = Query()
|
||||||
user = users.get(User.userid == userid)
|
user = users.get(User.userid == userid)
|
||||||
userbots = list(user["bots"])
|
if user:
|
||||||
if not did in userbots:
|
userbots = list(user["bots"])
|
||||||
userbots.append(did)
|
if not did in userbots:
|
||||||
|
userbots.append(did)
|
||||||
|
|
||||||
users.upsert({"bots": userbots}, User.userid == userid)
|
users.upsert({"bots": userbots}, User.userid == userid)
|
||||||
|
|
||||||
|
|
||||||
def user_remove_bot(userid, did):
|
def user_remove_bot(userid: str, did: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
users = opendb.table("users")
|
users = opendb.table("users")
|
||||||
User = Query()
|
User = Query()
|
||||||
user = users.get(User.userid == userid)
|
user = users.get(User.userid == userid)
|
||||||
userbots = list(user["bots"])
|
if user:
|
||||||
if did in userbots:
|
userbots = list(user["bots"])
|
||||||
userbots.remove(did)
|
if did in userbots:
|
||||||
|
userbots.remove(did)
|
||||||
|
|
||||||
users.upsert({"bots": userbots}, User.userid == userid)
|
users.upsert({"bots": userbots}, User.userid == userid)
|
||||||
|
|
||||||
|
|
||||||
def user_get_tokens(userid):
|
def user_get_tokens(userid: str) -> list[Document]:
|
||||||
tokens = db_get().table("tokens")
|
tokens = db_get().table("tokens")
|
||||||
return tokens.search(Query().userid == userid)
|
return tokens.search(Query().userid == userid)
|
||||||
|
|
||||||
|
|
||||||
def user_get_token(userid, token):
|
def user_get_token(userid: str, token: str) -> Document | None:
|
||||||
tokens = db_get().table("tokens")
|
tokens = db_get().table("tokens")
|
||||||
return tokens.get((Query().userid == userid) & (Query().token == token))
|
return tokens.get((Query().userid == userid) & (Query().token == token))
|
||||||
|
|
||||||
|
|
||||||
def user_add_token(userid, token):
|
def user_add_token(userid: str, token: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
tokens = opendb.table("tokens")
|
tokens = opendb.table("tokens")
|
||||||
|
|
@ -144,7 +150,7 @@ def user_add_token(userid, token):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def user_revoke_all_tokens(userid):
|
def user_revoke_all_tokens(userid: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
tokens = opendb.table("tokens")
|
tokens = opendb.table("tokens")
|
||||||
|
|
@ -153,7 +159,7 @@ def user_revoke_all_tokens(userid):
|
||||||
tokens.remove(doc_ids=[i.doc_id])
|
tokens.remove(doc_ids=[i.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def user_revoke_expired_tokens(userid):
|
def user_revoke_expired_tokens(userid: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
tokens = opendb.table("tokens")
|
tokens = opendb.table("tokens")
|
||||||
|
|
@ -166,7 +172,7 @@ def user_revoke_expired_tokens(userid):
|
||||||
tokens.remove(doc_ids=[i.doc_id])
|
tokens.remove(doc_ids=[i.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def user_revoke_token(userid: str, token: str):
|
def user_revoke_token(userid: str, token: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
tokens = opendb.table("tokens")
|
tokens = opendb.table("tokens")
|
||||||
|
|
@ -175,7 +181,7 @@ def user_revoke_token(userid: str, token: str):
|
||||||
tokens.remove(doc_ids=[tmptoken.doc_id])
|
tokens.remove(doc_ids=[tmptoken.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def user_add_authcode(userid, token, authcode):
|
def user_add_authcode(userid: str, token: str, authcode: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
tokens = opendb.table("tokens")
|
tokens = opendb.table("tokens")
|
||||||
|
|
@ -187,7 +193,7 @@ def user_add_authcode(userid, token, authcode):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def user_revoke_authcode(userid, token, authcode):
|
def user_revoke_authcode(userid: str, token: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
tokens = opendb.table("tokens")
|
tokens = opendb.table("tokens")
|
||||||
|
|
@ -199,7 +205,7 @@ def user_revoke_authcode(userid, token, authcode):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def revoke_expired_oauths():
|
def revoke_expired_oauths() -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
table = opendb.table("oauth")
|
table = opendb.table("oauth")
|
||||||
|
|
@ -214,7 +220,7 @@ def revoke_expired_oauths():
|
||||||
table.remove(doc_ids=[i.doc_id])
|
table.remove(doc_ids=[i.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def user_revoke_expired_oauths(userid):
|
def user_revoke_expired_oauths(userid: str) -> None:
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
table = opendb.table("oauth")
|
table = opendb.table("oauth")
|
||||||
|
|
@ -228,7 +234,7 @@ def user_revoke_expired_oauths(userid):
|
||||||
table.remove(doc_ids=[i.doc_id])
|
table.remove(doc_ids=[i.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def user_add_oauth(userid) -> OAuth:
|
def user_add_oauth(userid: str) -> OAuth:
|
||||||
user_revoke_expired_oauths(userid)
|
user_revoke_expired_oauths(userid)
|
||||||
opendb = db_get()
|
opendb = db_get()
|
||||||
with opendb:
|
with opendb:
|
||||||
|
|
@ -243,12 +249,12 @@ def user_add_oauth(userid) -> OAuth:
|
||||||
return oauth
|
return oauth
|
||||||
|
|
||||||
|
|
||||||
def token_by_authcode(authcode: str):
|
def token_by_authcode(authcode: str) -> Document | None:
|
||||||
tokens = db_get().table("tokens")
|
tokens = db_get().table("tokens")
|
||||||
return tokens.get(Query().authcode == authcode)
|
return tokens.get(Query().authcode == authcode)
|
||||||
|
|
||||||
|
|
||||||
def get_disconnected_xmpp_clients():
|
def get_disconnected_xmpp_clients() -> list[Document]:
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
Client = Query()
|
Client = Query()
|
||||||
return clients.search(Client.xmpp_connection == False)
|
return clients.search(Client.xmpp_connection == False)
|
||||||
|
|
@ -270,7 +276,7 @@ def check_authcode(uid: str, authcode: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def loginByItToken(authcode):
|
def loginByItToken(authcode: str) -> dict[str, str]:
|
||||||
bumperlog.debug(f"Checking for authcode: {authcode}")
|
bumperlog.debug(f"Checking for authcode: {authcode}")
|
||||||
tokens = db_get().table("tokens")
|
tokens = db_get().table("tokens")
|
||||||
tmpauth = tokens.get(
|
tmpauth = tokens.get(
|
||||||
|
|
@ -303,7 +309,7 @@ def check_token(uid: str, token: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def revoke_expired_tokens():
|
def revoke_expired_tokens() -> None:
|
||||||
tokens = db_get().table("tokens").all()
|
tokens = db_get().table("tokens").all()
|
||||||
for i in tokens:
|
for i in tokens:
|
||||||
if datetime.now() >= datetime.fromisoformat(i["expiration"]):
|
if datetime.now() >= datetime.fromisoformat(i["expiration"]):
|
||||||
|
|
@ -328,20 +334,20 @@ def bot_add(sn: str, did: str, devclass: str, resource: str, company: str) -> No
|
||||||
bot_full_upsert(newbot.asdict())
|
bot_full_upsert(newbot.asdict())
|
||||||
|
|
||||||
|
|
||||||
def bot_remove(did: str):
|
def bot_remove(did: str) -> None:
|
||||||
bots = db_get().table("bots")
|
bots = db_get().table("bots")
|
||||||
bot = bot_get(did)
|
bot = bot_get(did)
|
||||||
if bot:
|
if bot:
|
||||||
bots.remove(doc_ids=[bot.doc_id])
|
bots.remove(doc_ids=[bot.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def bot_get(did: str):
|
def bot_get(did: str) -> Document | None:
|
||||||
bots = db_get().table("bots")
|
bots = db_get().table("bots")
|
||||||
Bot = Query()
|
Bot = Query()
|
||||||
return bots.get(Bot.did == did)
|
return bots.get(Bot.did == did)
|
||||||
|
|
||||||
|
|
||||||
def bot_full_upsert(vacbot):
|
def bot_full_upsert(vacbot: dict[str, Any]) -> None:
|
||||||
bots = db_get().table("bots")
|
bots = db_get().table("bots")
|
||||||
Bot = Query()
|
Bot = Query()
|
||||||
if "did" in vacbot:
|
if "did" in vacbot:
|
||||||
|
|
@ -350,7 +356,7 @@ def bot_full_upsert(vacbot):
|
||||||
bumperlog.error(f"No DID in vacbot: {vacbot}")
|
bumperlog.error(f"No DID in vacbot: {vacbot}")
|
||||||
|
|
||||||
|
|
||||||
def bot_set_nick(did, nick):
|
def bot_set_nick(did: str, nick: str) -> None:
|
||||||
bots = db_get().table("bots")
|
bots = db_get().table("bots")
|
||||||
Bot = Query()
|
Bot = Query()
|
||||||
bots.upsert({"nick": nick}, Bot.did == did)
|
bots.upsert({"nick": nick}, Bot.did == did)
|
||||||
|
|
@ -362,7 +368,7 @@ def bot_set_mqtt(did: str, mqtt: bool) -> None:
|
||||||
bots.upsert({"mqtt_connection": mqtt}, Bot.did == did)
|
bots.upsert({"mqtt_connection": mqtt}, Bot.did == did)
|
||||||
|
|
||||||
|
|
||||||
def bot_set_xmpp(did, xmpp):
|
def bot_set_xmpp(did: str, xmpp: bool) -> None:
|
||||||
bots = db_get().table("bots")
|
bots = db_get().table("bots")
|
||||||
Bot = Query()
|
Bot = Query()
|
||||||
bots.upsert({"xmpp_connection": xmpp}, Bot.did == did)
|
bots.upsert({"xmpp_connection": xmpp}, Bot.did == did)
|
||||||
|
|
@ -380,20 +386,20 @@ def client_add(userid: str, realm: str, resource: str) -> None:
|
||||||
client_full_upsert(newclient.asdict())
|
client_full_upsert(newclient.asdict())
|
||||||
|
|
||||||
|
|
||||||
def client_remove(resource: str):
|
def client_remove(resource: str) -> None:
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
client = client_get(resource)
|
client = client_get(resource)
|
||||||
if client:
|
if client:
|
||||||
clients.remove(doc_ids=[client.doc_id])
|
clients.remove(doc_ids=[client.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def client_get(resource: str):
|
def client_get(resource: str) -> Document | None:
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
Client = Query()
|
Client = Query()
|
||||||
return clients.get(Client.resource == resource)
|
return clients.get(Client.resource == resource)
|
||||||
|
|
||||||
|
|
||||||
def client_full_upsert(client):
|
def client_full_upsert(client: dict[str, Any]) -> None:
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
Client = Query()
|
Client = Query()
|
||||||
clients.upsert(client, Client.resource == client["resource"])
|
clients.upsert(client, Client.resource == client["resource"])
|
||||||
|
|
@ -405,7 +411,7 @@ def client_set_mqtt(resource: str, mqtt: bool) -> None:
|
||||||
clients.upsert({"mqtt_connection": mqtt}, Client.resource == resource)
|
clients.upsert({"mqtt_connection": mqtt}, Client.resource == resource)
|
||||||
|
|
||||||
|
|
||||||
def client_set_xmpp(resource, xmpp):
|
def client_set_xmpp(resource: str, xmpp: bool) -> None:
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
Client = Query()
|
Client = Query()
|
||||||
clients.upsert({"xmpp_connection": xmpp}, Client.resource == resource)
|
clients.upsert({"xmpp_connection": xmpp}, Client.resource == resource)
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class EcoVacs_Login:
|
||||||
|
|
||||||
class EcoVacsHome_Login(EcoVacs_Login):
|
class EcoVacsHome_Login(EcoVacs_Login):
|
||||||
loginName = ""
|
loginName = ""
|
||||||
mobile = ""
|
mobile: str | None = ""
|
||||||
ucUid = ""
|
ucUid = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ def get_logger(name: str, rotate: RotatingFileHandler | None = None) -> logging.
|
||||||
) # Ignore this logger
|
) # Ignore this logger
|
||||||
get_logger("amqtt.broker", rotate)
|
get_logger("amqtt.broker", rotate)
|
||||||
get_logger("amqtt.mqtt.protocol", rotate)
|
get_logger("amqtt.mqtt.protocol", rotate)
|
||||||
|
elif name == "helperbot":
|
||||||
get_logger("gmqtt", rotate)
|
get_logger("gmqtt", rotate)
|
||||||
|
|
||||||
return logger
|
return logger
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import HTTPInternalServerError
|
from aiohttp.web_exceptions import HTTPInternalServerError
|
||||||
|
|
@ -35,29 +36,21 @@ from bumper.web.plugins import get_success_response
|
||||||
_logger = get_logger("confserver")
|
_logger = get_logger("confserver")
|
||||||
|
|
||||||
|
|
||||||
def generate_token(user):
|
def _generate_token(user: dict[str, Any]) -> str:
|
||||||
"""Generate token."""
|
"""Generate token."""
|
||||||
try:
|
token = uuid.uuid4().hex
|
||||||
tmpaccesstoken = uuid.uuid4().hex
|
user_add_token(user["userid"], token)
|
||||||
user_add_token(user["userid"], tmpaccesstoken)
|
return token
|
||||||
return tmpaccesstoken
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
_logger.exception(f"{e}")
|
|
||||||
|
|
||||||
|
|
||||||
def generate_authcode(user, countrycode, token):
|
def _generate_authcode(user: dict[str, Any], countrycode: str, token: str) -> str:
|
||||||
"""Generate auth token."""
|
"""Generate auth token."""
|
||||||
try:
|
tmpauthcode = f"{countrycode}_{uuid.uuid4().hex}"
|
||||||
tmpauthcode = f"{countrycode}_{uuid.uuid4().hex}"
|
user_add_authcode(user["userid"], token, tmpauthcode)
|
||||||
user_add_authcode(user["userid"], token, tmpauthcode)
|
return tmpauthcode
|
||||||
return tmpauthcode
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
_logger.exception(f"{e}")
|
|
||||||
|
|
||||||
|
|
||||||
async def login(request):
|
async def login(request: Request) -> Response:
|
||||||
"""Perform login."""
|
"""Perform login."""
|
||||||
try:
|
try:
|
||||||
user_devid = request.match_info.get("devid", "")
|
user_devid = request.match_info.get("devid", "")
|
||||||
|
|
@ -69,44 +62,48 @@ async def login(request):
|
||||||
not user_devid == ""
|
not user_devid == ""
|
||||||
): # Performing basic "auth" using devid, super insecure
|
): # Performing basic "auth" using devid, super insecure
|
||||||
user = user_by_deviceid(user_devid)
|
user = user_by_deviceid(user_devid)
|
||||||
if "checkLogin" in request.path:
|
if user:
|
||||||
_check_token(
|
if "checkLogin" in request.path:
|
||||||
apptype, countrycode, user, request.query["accessToken"]
|
_check_token(
|
||||||
)
|
apptype, countrycode, user, request.query["accessToken"]
|
||||||
else:
|
)
|
||||||
if "global_" in apptype: # EcoVacs Home
|
|
||||||
login_details = EcoVacsHome_Login()
|
|
||||||
login_details.ucUid = "fuid_{}".format(user["userid"])
|
|
||||||
login_details.loginName = "fusername_{}".format(user["userid"])
|
|
||||||
login_details.mobile = None
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
login_details = EcoVacs_Login()
|
login_details: EcoVacsHome_Login | EcoVacs_Login
|
||||||
|
if "global_" in apptype: # EcoVacs Home
|
||||||
|
login_details = EcoVacsHome_Login()
|
||||||
|
login_details.ucUid = "fuid_{}".format(user["userid"])
|
||||||
|
login_details.loginName = "fusername_{}".format(
|
||||||
|
user["userid"]
|
||||||
|
)
|
||||||
|
login_details.mobile = None
|
||||||
|
|
||||||
# Deactivate old tokens and authcodes
|
else:
|
||||||
user_revoke_expired_tokens(user["userid"])
|
login_details = EcoVacs_Login()
|
||||||
|
|
||||||
login_details.accessToken = generate_token(user)
|
# Deactivate old tokens and authcodes
|
||||||
login_details.uid = "fuid_{}".format(user["userid"])
|
user_revoke_expired_tokens(user["userid"])
|
||||||
login_details.username = "fusername_{}".format(user["userid"])
|
|
||||||
login_details.country = countrycode
|
|
||||||
login_details.email = "null@null.com"
|
|
||||||
|
|
||||||
body = {
|
login_details.accessToken = _generate_token(user)
|
||||||
"code": API_ERRORS[RETURN_API_SUCCESS],
|
login_details.uid = "fuid_{}".format(user["userid"])
|
||||||
"data": json.loads(login_details.toJSON()),
|
login_details.username = "fusername_{}".format(user["userid"])
|
||||||
# {
|
login_details.country = countrycode
|
||||||
# "accessToken": self.generate_token(tmpuser), # Generate a token
|
login_details.email = "null@null.com"
|
||||||
# "country": countrycode,
|
|
||||||
# "email": "null@null.com",
|
|
||||||
# "uid": "fuid_{}".format(tmpuser["userid"]),
|
|
||||||
# "username": "fusername_{}".format(tmpuser["userid"]),
|
|
||||||
# },
|
|
||||||
"msg": "操作成功",
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
body = {
|
||||||
|
"code": API_ERRORS[RETURN_API_SUCCESS],
|
||||||
|
"data": json.loads(login_details.toJSON()),
|
||||||
|
# {
|
||||||
|
# "accessToken": self.generate_token(tmpuser), # Generate a token
|
||||||
|
# "country": countrycode,
|
||||||
|
# "email": "null@null.com",
|
||||||
|
# "uid": "fuid_{}".format(tmpuser["userid"]),
|
||||||
|
# "username": "fusername_{}".format(tmpuser["userid"]),
|
||||||
|
# },
|
||||||
|
"msg": "操作成功",
|
||||||
|
"time": get_current_time_as_millis(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
"code": ERR_USER_NOT_ACTIVATED,
|
"code": ERR_USER_NOT_ACTIVATED,
|
||||||
|
|
@ -125,6 +122,8 @@ async def login(request):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.exception(f"{e}")
|
_logger.exception(f"{e}")
|
||||||
|
|
||||||
|
raise HTTPInternalServerError
|
||||||
|
|
||||||
|
|
||||||
async def get_authcode(request: Request) -> Response:
|
async def get_authcode(request: Request) -> Response:
|
||||||
"""Get auth code."""
|
"""Get auth code."""
|
||||||
|
|
@ -142,7 +141,7 @@ async def get_authcode(request: Request) -> Response:
|
||||||
if "authcode" in token:
|
if "authcode" in token:
|
||||||
authcode = token["authcode"]
|
authcode = token["authcode"]
|
||||||
else:
|
else:
|
||||||
authcode = generate_authcode(
|
authcode = _generate_authcode(
|
||||||
user,
|
user,
|
||||||
request.match_info.get("country", "us"),
|
request.match_info.get("country", "us"),
|
||||||
request.query["accessToken"],
|
request.query["accessToken"],
|
||||||
|
|
@ -170,10 +169,12 @@ async def get_authcode(request: Request) -> Response:
|
||||||
raise HTTPInternalServerError
|
raise HTTPInternalServerError
|
||||||
|
|
||||||
|
|
||||||
def _check_token(apptype, countrycode, user, token):
|
def _check_token(
|
||||||
|
apptype: str, countrycode: str, user: dict[str, Any], token: str
|
||||||
|
) -> Response:
|
||||||
try:
|
try:
|
||||||
if db.check_token(user["userid"], token):
|
if db.check_token(user["userid"], token):
|
||||||
|
login_details: EcoVacsHome_Login | EcoVacs_Login
|
||||||
if "global_" in apptype: # EcoVacs Home
|
if "global_" in apptype: # EcoVacs Home
|
||||||
login_details = EcoVacsHome_Login()
|
login_details = EcoVacsHome_Login()
|
||||||
login_details.ucUid = "fuid_{}".format(user["userid"])
|
login_details.ucUid = "fuid_{}".format(user["userid"])
|
||||||
|
|
@ -215,13 +216,18 @@ def _check_token(apptype, countrycode, user, token):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.exception(f"{e}")
|
_logger.exception(f"{e}")
|
||||||
|
|
||||||
|
raise HTTPInternalServerError
|
||||||
|
|
||||||
def _auth_any(devid, apptype, country, request):
|
|
||||||
|
def _auth_any(
|
||||||
|
devid: str, apptype: str, country: str, request: Request
|
||||||
|
) -> dict[str, Any]:
|
||||||
try:
|
try:
|
||||||
user_devid = devid
|
user_devid = devid
|
||||||
countrycode = country
|
countrycode = country
|
||||||
user = user_by_deviceid(user_devid)
|
user = user_by_deviceid(user_devid)
|
||||||
bots = db_get().table("bots").all()
|
bots = db_get().table("bots").all()
|
||||||
|
login_details: EcoVacs_Login | EcoVacsHome_Login
|
||||||
|
|
||||||
if user: # Default to user 0
|
if user: # Default to user 0
|
||||||
tmpuser = user
|
tmpuser = user
|
||||||
|
|
@ -233,7 +239,7 @@ def _auth_any(devid, apptype, country, request):
|
||||||
else:
|
else:
|
||||||
login_details = EcoVacs_Login()
|
login_details = EcoVacs_Login()
|
||||||
|
|
||||||
login_details.accessToken = generate_token(tmpuser)
|
login_details.accessToken = _generate_token(tmpuser)
|
||||||
login_details.uid = "fuid_{}".format(tmpuser["userid"])
|
login_details.uid = "fuid_{}".format(tmpuser["userid"])
|
||||||
login_details.username = "fusername_{}".format(tmpuser["userid"])
|
login_details.username = "fusername_{}".format(tmpuser["userid"])
|
||||||
login_details.country = countrycode
|
login_details.country = countrycode
|
||||||
|
|
@ -241,7 +247,9 @@ def _auth_any(devid, apptype, country, request):
|
||||||
user_add_device(tmpuser["userid"], user_devid)
|
user_add_device(tmpuser["userid"], user_devid)
|
||||||
else:
|
else:
|
||||||
user_add("tmpuser") # Add a new user
|
user_add("tmpuser") # Add a new user
|
||||||
tmpuser = user_get("tmpuser")
|
tmp = user_get("tmpuser")
|
||||||
|
assert tmp
|
||||||
|
tmpuser = tmp
|
||||||
if "global_" in apptype: # EcoVacs Home
|
if "global_" in apptype: # EcoVacs Home
|
||||||
login_details = EcoVacsHome_Login()
|
login_details = EcoVacsHome_Login()
|
||||||
login_details.ucUid = "fuid_{}".format(tmpuser["userid"])
|
login_details.ucUid = "fuid_{}".format(tmpuser["userid"])
|
||||||
|
|
@ -250,7 +258,7 @@ def _auth_any(devid, apptype, country, request):
|
||||||
else:
|
else:
|
||||||
login_details = EcoVacs_Login()
|
login_details = EcoVacs_Login()
|
||||||
|
|
||||||
login_details.accessToken = generate_token(tmpuser)
|
login_details.accessToken = _generate_token(tmpuser)
|
||||||
login_details.uid = "fuid_{}".format(tmpuser["userid"])
|
login_details.uid = "fuid_{}".format(tmpuser["userid"])
|
||||||
login_details.username = "fusername_{}".format(tmpuser["userid"])
|
login_details.username = "fusername_{}".format(tmpuser["userid"])
|
||||||
login_details.country = countrycode
|
login_details.country = countrycode
|
||||||
|
|
@ -267,7 +275,7 @@ def _auth_any(devid, apptype, country, request):
|
||||||
checkToken = _check_token(
|
checkToken = _check_token(
|
||||||
apptype, countrycode, tmpuser, request.query["accessToken"]
|
apptype, countrycode, tmpuser, request.query["accessToken"]
|
||||||
)
|
)
|
||||||
isGood = json.loads(checkToken.text)
|
isGood: dict[str, Any] = json.loads(checkToken.text)
|
||||||
if isGood["code"] == "0000":
|
if isGood["code"] == "0000":
|
||||||
return isGood
|
return isGood
|
||||||
|
|
||||||
|
|
@ -292,3 +300,4 @@ def _auth_any(devid, apptype, country, request):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.exception(f"{e}")
|
_logger.exception(f"{e}")
|
||||||
|
return {}
|
||||||
|
|
|
||||||
|
|
@ -181,15 +181,17 @@ async def _handle_appsvr_service_list(_: Request) -> Response:
|
||||||
async def _handle_appsvr_oauth_callback(request: Request) -> Response:
|
async def _handle_appsvr_oauth_callback(request: Request) -> Response:
|
||||||
try:
|
try:
|
||||||
token = token_by_authcode(request.query["code"])
|
token = token_by_authcode(request.query["code"])
|
||||||
oauth = user_add_oauth(token["userid"])
|
if token:
|
||||||
body = {
|
oauth = user_add_oauth(token["userid"])
|
||||||
"code": 0,
|
if oauth:
|
||||||
"data": oauth.toResponse(),
|
body = {
|
||||||
"ret": "ok",
|
"code": 0,
|
||||||
"todo": "result",
|
"data": oauth.toResponse(),
|
||||||
}
|
"ret": "ok",
|
||||||
|
"todo": "result",
|
||||||
|
}
|
||||||
|
|
||||||
return web.json_response(body)
|
return web.json_response(body)
|
||||||
|
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
logging.error("Unexpected exception occurred", exc_info=True)
|
logging.error("Unexpected exception occurred", exc_info=True)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ async def _handle_dim_devmanager(request: Request) -> Response:
|
||||||
|
|
||||||
if did != "":
|
if did != "":
|
||||||
bot = bot_get(did)
|
bot = bot_get(did)
|
||||||
if bot["company"] == "eco-ng" and bot["mqtt_connection"]:
|
if bot and bot["company"] == "eco-ng" and bot["mqtt_connection"]:
|
||||||
retcmd = await bumper.mqtt_helperbot.send_command(json_body, randomid)
|
retcmd = await bumper.mqtt_helperbot.send_command(json_body, randomid)
|
||||||
body = retcmd
|
body = retcmd
|
||||||
logging.debug("Send Bot - %s", json_body)
|
logging.debug("Send Bot - %s", json_body)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ async def _handle_devmanager_bot_command(request: Request) -> Response:
|
||||||
|
|
||||||
if did != "":
|
if did != "":
|
||||||
bot = bot_get(did)
|
bot = bot_get(did)
|
||||||
if bot["company"] == "eco-ng":
|
if bot and bot["company"] == "eco-ng":
|
||||||
retcmd = await bumper.mqtt_helperbot.send_command(json_body, randomid)
|
retcmd = await bumper.mqtt_helperbot.send_command(json_body, randomid)
|
||||||
body = retcmd
|
body = retcmd
|
||||||
logging.debug("Send Bot - %s", json_body)
|
logging.debug("Send Bot - %s", json_body)
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ async def _handle_lg_log(request: Request) -> Response:
|
||||||
|
|
||||||
if did != "":
|
if did != "":
|
||||||
bot = bot_get(did)
|
bot = bot_get(did)
|
||||||
if bot["company"] == "eco-ng":
|
if bot and bot["company"] == "eco-ng":
|
||||||
retcmd = await bumper.mqtt_helperbot.send_command(json_body, randomid)
|
retcmd = await bumper.mqtt_helperbot.send_command(json_body, randomid)
|
||||||
body = retcmd
|
body = retcmd
|
||||||
logging.debug("Send Bot - %s", json_body)
|
logging.debug("Send Bot - %s", json_body)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,23 @@
|
||||||
{
|
{
|
||||||
"currentVersion": 231,
|
|
||||||
"areaList": [
|
"areaList": [
|
||||||
{ "areaKey": "JP", "chsName": "日本", "enName": "Japan", "pyFirst": "R" },
|
{
|
||||||
|
"areaKey": "JP",
|
||||||
|
"chsName": "日本",
|
||||||
|
"enName": "Japan",
|
||||||
|
"pyFirst": "R"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "MY",
|
"areaKey": "MY",
|
||||||
"chsName": "马来西亚",
|
"chsName": "马来西亚",
|
||||||
"enName": "Malaysia",
|
"enName": "Malaysia",
|
||||||
"pyFirst": "M"
|
"pyFirst": "M"
|
||||||
},
|
},
|
||||||
{ "areaKey": "DE", "chsName": "德国", "enName": "Germany", "pyFirst": "D" },
|
{
|
||||||
|
"areaKey": "DE",
|
||||||
|
"chsName": "德国",
|
||||||
|
"enName": "Germany",
|
||||||
|
"pyFirst": "D"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "LI",
|
"areaKey": "LI",
|
||||||
"chsName": "列支敦斯登",
|
"chsName": "列支敦斯登",
|
||||||
|
|
@ -21,8 +30,18 @@
|
||||||
"enName": "Austria",
|
"enName": "Austria",
|
||||||
"pyFirst": "A"
|
"pyFirst": "A"
|
||||||
},
|
},
|
||||||
{ "areaKey": "TW", "chsName": "台湾", "enName": "Taiwan", "pyFirst": "T" },
|
{
|
||||||
{ "areaKey": "FR", "chsName": "法国", "enName": "France", "pyFirst": "F" },
|
"areaKey": "TW",
|
||||||
|
"chsName": "台湾",
|
||||||
|
"enName": "Taiwan",
|
||||||
|
"pyFirst": "T"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "FR",
|
||||||
|
"chsName": "法国",
|
||||||
|
"enName": "France",
|
||||||
|
"pyFirst": "F"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "CN",
|
"areaKey": "CN",
|
||||||
"chsName": "中国大陆",
|
"chsName": "中国大陆",
|
||||||
|
|
@ -101,7 +120,12 @@
|
||||||
"enName": "Vanuatu",
|
"enName": "Vanuatu",
|
||||||
"pyFirst": "W"
|
"pyFirst": "W"
|
||||||
},
|
},
|
||||||
{ "areaKey": "IN", "chsName": "印度", "enName": "India", "pyFirst": "Y" },
|
{
|
||||||
|
"areaKey": "IN",
|
||||||
|
"chsName": "印度",
|
||||||
|
"enName": "India",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "CM",
|
"areaKey": "CM",
|
||||||
"chsName": "喀麦隆",
|
"chsName": "喀麦隆",
|
||||||
|
|
@ -126,7 +150,12 @@
|
||||||
"enName": "Cayman Islands",
|
"enName": "Cayman Islands",
|
||||||
"pyFirst": "K"
|
"pyFirst": "K"
|
||||||
},
|
},
|
||||||
{ "areaKey": "QA", "chsName": "卡塔尔", "enName": "Qatar", "pyFirst": "K" },
|
{
|
||||||
|
"areaKey": "QA",
|
||||||
|
"chsName": "卡塔尔",
|
||||||
|
"enName": "Qatar",
|
||||||
|
"pyFirst": "K"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "AZ",
|
"areaKey": "AZ",
|
||||||
"chsName": "阿塞拜疆",
|
"chsName": "阿塞拜疆",
|
||||||
|
|
@ -157,7 +186,12 @@
|
||||||
"enName": "Colombia",
|
"enName": "Colombia",
|
||||||
"pyFirst": "G"
|
"pyFirst": "G"
|
||||||
},
|
},
|
||||||
{ "areaKey": "IR", "chsName": "伊朗", "enName": "Iran", "pyFirst": "Y" },
|
{
|
||||||
|
"areaKey": "IR",
|
||||||
|
"chsName": "伊朗",
|
||||||
|
"enName": "Iran",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "ZA",
|
"areaKey": "ZA",
|
||||||
"chsName": "南非",
|
"chsName": "南非",
|
||||||
|
|
@ -170,8 +204,18 @@
|
||||||
"enName": "Uruguay",
|
"enName": "Uruguay",
|
||||||
"pyFirst": "W"
|
"pyFirst": "W"
|
||||||
},
|
},
|
||||||
{ "areaKey": "GU", "chsName": "关岛", "enName": "Guam", "pyFirst": "G" },
|
{
|
||||||
{ "areaKey": "GH", "chsName": "加纳", "enName": "Ghana", "pyFirst": "J" },
|
"areaKey": "GU",
|
||||||
|
"chsName": "关岛",
|
||||||
|
"enName": "Guam",
|
||||||
|
"pyFirst": "G"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "GH",
|
||||||
|
"chsName": "加纳",
|
||||||
|
"enName": "Ghana",
|
||||||
|
"pyFirst": "J"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "GN",
|
"areaKey": "GN",
|
||||||
"chsName": "几内亚",
|
"chsName": "几内亚",
|
||||||
|
|
@ -184,16 +228,36 @@
|
||||||
"enName": "Marshall Islands",
|
"enName": "Marshall Islands",
|
||||||
"pyFirst": "M"
|
"pyFirst": "M"
|
||||||
},
|
},
|
||||||
{ "areaKey": "SE", "chsName": "瑞典", "enName": "Sweden", "pyFirst": "R" },
|
{
|
||||||
|
"areaKey": "SE",
|
||||||
|
"chsName": "瑞典",
|
||||||
|
"enName": "Sweden",
|
||||||
|
"pyFirst": "R"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "SB",
|
"areaKey": "SB",
|
||||||
"chsName": "所罗门群岛",
|
"chsName": "所罗门群岛",
|
||||||
"enName": "Solomon Islands",
|
"enName": "Solomon Islands",
|
||||||
"pyFirst": "S"
|
"pyFirst": "S"
|
||||||
},
|
},
|
||||||
{ "areaKey": "NE", "chsName": "尼日尔", "enName": "Niger", "pyFirst": "N" },
|
{
|
||||||
{ "areaKey": "HT", "chsName": "海地", "enName": "Haiti", "pyFirst": "H" },
|
"areaKey": "NE",
|
||||||
{ "areaKey": "PL", "chsName": "波兰", "enName": "Poland", "pyFirst": "B" },
|
"chsName": "尼日尔",
|
||||||
|
"enName": "Niger",
|
||||||
|
"pyFirst": "N"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "HT",
|
||||||
|
"chsName": "海地",
|
||||||
|
"enName": "Haiti",
|
||||||
|
"pyFirst": "H"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "PL",
|
||||||
|
"chsName": "波兰",
|
||||||
|
"enName": "Poland",
|
||||||
|
"pyFirst": "B"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "DO",
|
"areaKey": "DO",
|
||||||
"chsName": "多米尼加共和国",
|
"chsName": "多米尼加共和国",
|
||||||
|
|
@ -230,7 +294,12 @@
|
||||||
"enName": "Kyrgyzstan",
|
"enName": "Kyrgyzstan",
|
||||||
"pyFirst": "J"
|
"pyFirst": "J"
|
||||||
},
|
},
|
||||||
{ "areaKey": "JO", "chsName": "约旦", "enName": "Jordan", "pyFirst": "Y" },
|
{
|
||||||
|
"areaKey": "JO",
|
||||||
|
"chsName": "约旦",
|
||||||
|
"enName": "Jordan",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "IL",
|
"areaKey": "IL",
|
||||||
"chsName": "以色列",
|
"chsName": "以色列",
|
||||||
|
|
@ -291,7 +360,12 @@
|
||||||
"enName": "Ethiopia",
|
"enName": "Ethiopia",
|
||||||
"pyFirst": "A"
|
"pyFirst": "A"
|
||||||
},
|
},
|
||||||
{ "areaKey": "CL", "chsName": "智利", "enName": "Chile", "pyFirst": "Z" },
|
{
|
||||||
|
"areaKey": "CL",
|
||||||
|
"chsName": "智利",
|
||||||
|
"enName": "Chile",
|
||||||
|
"pyFirst": "Z"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "GP",
|
"areaKey": "GP",
|
||||||
"chsName": "瓜德罗普岛",
|
"chsName": "瓜德罗普岛",
|
||||||
|
|
@ -328,7 +402,12 @@
|
||||||
"enName": "Maldives",
|
"enName": "Maldives",
|
||||||
"pyFirst": "M"
|
"pyFirst": "M"
|
||||||
},
|
},
|
||||||
{ "areaKey": "CU", "chsName": "古巴", "enName": "Cuba", "pyFirst": "G" },
|
{
|
||||||
|
"areaKey": "CU",
|
||||||
|
"chsName": "古巴",
|
||||||
|
"enName": "Cuba",
|
||||||
|
"pyFirst": "G"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "LS",
|
"areaKey": "LS",
|
||||||
"chsName": "莱索托",
|
"chsName": "莱索托",
|
||||||
|
|
@ -383,7 +462,12 @@
|
||||||
"enName": "Latvia",
|
"enName": "Latvia",
|
||||||
"pyFirst": "L"
|
"pyFirst": "L"
|
||||||
},
|
},
|
||||||
{ "areaKey": "NO", "chsName": "挪威", "enName": "Norway", "pyFirst": "N" },
|
{
|
||||||
|
"areaKey": "NO",
|
||||||
|
"chsName": "挪威",
|
||||||
|
"enName": "Norway",
|
||||||
|
"pyFirst": "N"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "BE",
|
"areaKey": "BE",
|
||||||
"chsName": "比利时",
|
"chsName": "比利时",
|
||||||
|
|
@ -456,7 +540,12 @@
|
||||||
"enName": "Bangladesh",
|
"enName": "Bangladesh",
|
||||||
"pyFirst": "M"
|
"pyFirst": "M"
|
||||||
},
|
},
|
||||||
{ "areaKey": "TD", "chsName": "乍得", "enName": "Chad", "pyFirst": "Z" },
|
{
|
||||||
|
"areaKey": "TD",
|
||||||
|
"chsName": "乍得",
|
||||||
|
"enName": "Chad",
|
||||||
|
"pyFirst": "Z"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "LT",
|
"areaKey": "LT",
|
||||||
"chsName": "立陶宛",
|
"chsName": "立陶宛",
|
||||||
|
|
@ -481,7 +570,12 @@
|
||||||
"enName": "Bahamas",
|
"enName": "Bahamas",
|
||||||
"pyFirst": "B"
|
"pyFirst": "B"
|
||||||
},
|
},
|
||||||
{ "areaKey": "MM", "chsName": "缅甸", "enName": "Myanmar", "pyFirst": "M" },
|
{
|
||||||
|
"areaKey": "MM",
|
||||||
|
"chsName": "缅甸",
|
||||||
|
"enName": "Myanmar",
|
||||||
|
"pyFirst": "M"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "BI",
|
"areaKey": "BI",
|
||||||
"chsName": "布隆迪",
|
"chsName": "布隆迪",
|
||||||
|
|
@ -500,8 +594,18 @@
|
||||||
"enName": "Slovakia",
|
"enName": "Slovakia",
|
||||||
"pyFirst": "S"
|
"pyFirst": "S"
|
||||||
},
|
},
|
||||||
{ "areaKey": "FI", "chsName": "芬兰", "enName": "Finland", "pyFirst": "F" },
|
{
|
||||||
{ "areaKey": "GA", "chsName": "加蓬", "enName": "Gabon", "pyFirst": "J" },
|
"areaKey": "FI",
|
||||||
|
"chsName": "芬兰",
|
||||||
|
"enName": "Finland",
|
||||||
|
"pyFirst": "F"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "GA",
|
||||||
|
"chsName": "加蓬",
|
||||||
|
"enName": "Gabon",
|
||||||
|
"pyFirst": "J"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "DZ",
|
"areaKey": "DZ",
|
||||||
"chsName": "阿尔及利亚",
|
"chsName": "阿尔及利亚",
|
||||||
|
|
@ -520,7 +624,12 @@
|
||||||
"enName": "Zambia",
|
"enName": "Zambia",
|
||||||
"pyFirst": "Z"
|
"pyFirst": "Z"
|
||||||
},
|
},
|
||||||
{ "areaKey": "NU", "chsName": "纽埃", "enName": "Niue", "pyFirst": "N" },
|
{
|
||||||
|
"areaKey": "NU",
|
||||||
|
"chsName": "纽埃",
|
||||||
|
"enName": "Niue",
|
||||||
|
"pyFirst": "N"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "ER",
|
"areaKey": "ER",
|
||||||
"chsName": "厄立特里亚国",
|
"chsName": "厄立特里亚国",
|
||||||
|
|
@ -533,7 +642,12 @@
|
||||||
"enName": "Hong Kong",
|
"enName": "Hong Kong",
|
||||||
"pyFirst": "X"
|
"pyFirst": "X"
|
||||||
},
|
},
|
||||||
{ "areaKey": "IT", "chsName": "意大利", "enName": "Italy", "pyFirst": "Y" },
|
{
|
||||||
|
"areaKey": "IT",
|
||||||
|
"chsName": "意大利",
|
||||||
|
"enName": "Italy",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "MS",
|
"areaKey": "MS",
|
||||||
"chsName": "蒙特色拉特岛",
|
"chsName": "蒙特色拉特岛",
|
||||||
|
|
@ -546,9 +660,24 @@
|
||||||
"enName": "Estonia",
|
"enName": "Estonia",
|
||||||
"pyFirst": "A"
|
"pyFirst": "A"
|
||||||
},
|
},
|
||||||
{ "areaKey": "WS", "chsName": "萨摩亚", "enName": "Samoa", "pyFirst": "S" },
|
{
|
||||||
{ "areaKey": "TG", "chsName": "多哥", "enName": "Togo", "pyFirst": "D" },
|
"areaKey": "WS",
|
||||||
{ "areaKey": "ML", "chsName": "马里", "enName": "Mali", "pyFirst": "M" },
|
"chsName": "萨摩亚",
|
||||||
|
"enName": "Samoa",
|
||||||
|
"pyFirst": "S"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "TG",
|
||||||
|
"chsName": "多哥",
|
||||||
|
"enName": "Togo",
|
||||||
|
"pyFirst": "D"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "ML",
|
||||||
|
"chsName": "马里",
|
||||||
|
"enName": "Mali",
|
||||||
|
"pyFirst": "M"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "GF",
|
"areaKey": "GF",
|
||||||
"chsName": "法属圭亚那",
|
"chsName": "法属圭亚那",
|
||||||
|
|
@ -567,8 +696,18 @@
|
||||||
"enName": "Indonesia",
|
"enName": "Indonesia",
|
||||||
"pyFirst": "Y"
|
"pyFirst": "Y"
|
||||||
},
|
},
|
||||||
{ "areaKey": "KE", "chsName": "肯尼亚", "enName": "Kenya", "pyFirst": "K" },
|
{
|
||||||
{ "areaKey": "EG", "chsName": "埃及", "enName": "Egypt", "pyFirst": "A" },
|
"areaKey": "KE",
|
||||||
|
"chsName": "肯尼亚",
|
||||||
|
"enName": "Kenya",
|
||||||
|
"pyFirst": "K"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "EG",
|
||||||
|
"chsName": "埃及",
|
||||||
|
"enName": "Egypt",
|
||||||
|
"pyFirst": "A"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "NF",
|
"areaKey": "NF",
|
||||||
"chsName": "诺福克岛",
|
"chsName": "诺福克岛",
|
||||||
|
|
@ -587,7 +726,12 @@
|
||||||
"enName": "Turkey",
|
"enName": "Turkey",
|
||||||
"pyFirst": "T"
|
"pyFirst": "T"
|
||||||
},
|
},
|
||||||
{ "areaKey": "DK", "chsName": "丹麦", "enName": "Denmark", "pyFirst": "D" },
|
{
|
||||||
|
"areaKey": "DK",
|
||||||
|
"chsName": "丹麦",
|
||||||
|
"enName": "Denmark",
|
||||||
|
"pyFirst": "D"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "AD",
|
"areaKey": "AD",
|
||||||
"chsName": "安道尔",
|
"chsName": "安道尔",
|
||||||
|
|
@ -624,7 +768,12 @@
|
||||||
"enName": "East Timor",
|
"enName": "East Timor",
|
||||||
"pyFirst": "D"
|
"pyFirst": "D"
|
||||||
},
|
},
|
||||||
{ "areaKey": "LY", "chsName": "利比亚", "enName": "Libya", "pyFirst": "L" },
|
{
|
||||||
|
"areaKey": "LY",
|
||||||
|
"chsName": "利比亚",
|
||||||
|
"enName": "Libya",
|
||||||
|
"pyFirst": "L"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "RW",
|
"areaKey": "RW",
|
||||||
"chsName": "卢旺达",
|
"chsName": "卢旺达",
|
||||||
|
|
@ -697,14 +846,24 @@
|
||||||
"enName": "Guatemala",
|
"enName": "Guatemala",
|
||||||
"pyFirst": "W"
|
"pyFirst": "W"
|
||||||
},
|
},
|
||||||
{ "areaKey": "BT", "chsName": "不丹", "enName": "Bhutan", "pyFirst": "B" },
|
{
|
||||||
|
"areaKey": "BT",
|
||||||
|
"chsName": "不丹",
|
||||||
|
"enName": "Bhutan",
|
||||||
|
"pyFirst": "B"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "AI",
|
"areaKey": "AI",
|
||||||
"chsName": "安圭拉岛",
|
"chsName": "安圭拉岛",
|
||||||
"enName": "Anguilla",
|
"enName": "Anguilla",
|
||||||
"pyFirst": "A"
|
"pyFirst": "A"
|
||||||
},
|
},
|
||||||
{ "areaKey": "OM", "chsName": "阿曼", "enName": "Oman", "pyFirst": "A" },
|
{
|
||||||
|
"areaKey": "OM",
|
||||||
|
"chsName": "阿曼",
|
||||||
|
"enName": "Oman",
|
||||||
|
"pyFirst": "A"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "KI",
|
"areaKey": "KI",
|
||||||
"chsName": "基里巴斯",
|
"chsName": "基里巴斯",
|
||||||
|
|
@ -717,7 +876,12 @@
|
||||||
"enName": "Ukraine",
|
"enName": "Ukraine",
|
||||||
"pyFirst": "W"
|
"pyFirst": "W"
|
||||||
},
|
},
|
||||||
{ "areaKey": "YE", "chsName": "也门", "enName": "Yemen", "pyFirst": "Y" },
|
{
|
||||||
|
"areaKey": "YE",
|
||||||
|
"chsName": "也门",
|
||||||
|
"enName": "Yemen",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "DR",
|
"areaKey": "DR",
|
||||||
"chsName": "刚果民主共和国",
|
"chsName": "刚果民主共和国",
|
||||||
|
|
@ -754,14 +918,24 @@
|
||||||
"enName": "Bosnia Hercegovina",
|
"enName": "Bosnia Hercegovina",
|
||||||
"pyFirst": "B"
|
"pyFirst": "B"
|
||||||
},
|
},
|
||||||
{ "areaKey": "MO", "chsName": "澳门", "enName": "Macao", "pyFirst": "A" },
|
{
|
||||||
|
"areaKey": "MO",
|
||||||
|
"chsName": "澳门",
|
||||||
|
"enName": "Macao",
|
||||||
|
"pyFirst": "A"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "KN",
|
"areaKey": "KN",
|
||||||
"chsName": "圣基茨和尼维斯",
|
"chsName": "圣基茨和尼维斯",
|
||||||
"enName": "Saint Kitts and Nevis",
|
"enName": "Saint Kitts and Nevis",
|
||||||
"pyFirst": "S"
|
"pyFirst": "S"
|
||||||
},
|
},
|
||||||
{ "areaKey": "TO", "chsName": "汤加", "enName": "Tonga", "pyFirst": "T" },
|
{
|
||||||
|
"areaKey": "TO",
|
||||||
|
"chsName": "汤加",
|
||||||
|
"enName": "Tonga",
|
||||||
|
"pyFirst": "T"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "NG",
|
"areaKey": "NG",
|
||||||
"chsName": "尼日利亚",
|
"chsName": "尼日利亚",
|
||||||
|
|
@ -780,7 +954,12 @@
|
||||||
"enName": "Central African Republic",
|
"enName": "Central African Republic",
|
||||||
"pyFirst": "Z"
|
"pyFirst": "Z"
|
||||||
},
|
},
|
||||||
{ "areaKey": "PE", "chsName": "秘鲁", "enName": "Peru", "pyFirst": "M" },
|
{
|
||||||
|
"areaKey": "PE",
|
||||||
|
"chsName": "秘鲁",
|
||||||
|
"enName": "Peru",
|
||||||
|
"pyFirst": "M"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "PG",
|
"areaKey": "PG",
|
||||||
"chsName": "巴布亚新几内亚",
|
"chsName": "巴布亚新几内亚",
|
||||||
|
|
@ -805,10 +984,30 @@
|
||||||
"enName": "Bolivia",
|
"enName": "Bolivia",
|
||||||
"pyFirst": "B"
|
"pyFirst": "B"
|
||||||
},
|
},
|
||||||
{ "areaKey": "IQ", "chsName": "伊拉克", "enName": "Iraq", "pyFirst": "Y" },
|
{
|
||||||
{ "areaKey": "NP", "chsName": "尼泊尔", "enName": "Nepal", "pyFirst": "N" },
|
"areaKey": "IQ",
|
||||||
{ "areaKey": "BJ", "chsName": "贝宁", "enName": "Benin", "pyFirst": "B" },
|
"chsName": "伊拉克",
|
||||||
{ "areaKey": "VN", "chsName": "越南", "enName": "Vietnam", "pyFirst": "Y" },
|
"enName": "Iraq",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "NP",
|
||||||
|
"chsName": "尼泊尔",
|
||||||
|
"enName": "Nepal",
|
||||||
|
"pyFirst": "N"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "BJ",
|
||||||
|
"chsName": "贝宁",
|
||||||
|
"enName": "Benin",
|
||||||
|
"pyFirst": "B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"areaKey": "VN",
|
||||||
|
"chsName": "越南",
|
||||||
|
"enName": "Vietnam",
|
||||||
|
"pyFirst": "Y"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "NI",
|
"areaKey": "NI",
|
||||||
"chsName": "尼加拉瓜",
|
"chsName": "尼加拉瓜",
|
||||||
|
|
@ -833,7 +1032,12 @@
|
||||||
"enName": "San Marino",
|
"enName": "San Marino",
|
||||||
"pyFirst": "S"
|
"pyFirst": "S"
|
||||||
},
|
},
|
||||||
{ "areaKey": "NR", "chsName": "瑙鲁", "enName": "Nauru", "pyFirst": "N" },
|
{
|
||||||
|
"areaKey": "NR",
|
||||||
|
"chsName": "瑙鲁",
|
||||||
|
"enName": "Nauru",
|
||||||
|
"pyFirst": "N"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "BN",
|
"areaKey": "BN",
|
||||||
"chsName": "文莱",
|
"chsName": "文莱",
|
||||||
|
|
@ -846,7 +1050,12 @@
|
||||||
"enName": "Mozambique",
|
"enName": "Mozambique",
|
||||||
"pyFirst": "M"
|
"pyFirst": "M"
|
||||||
},
|
},
|
||||||
{ "areaKey": "GR", "chsName": "希腊", "enName": "Greece", "pyFirst": "X" },
|
{
|
||||||
|
"areaKey": "GR",
|
||||||
|
"chsName": "希腊",
|
||||||
|
"enName": "Greece",
|
||||||
|
"pyFirst": "X"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "TN",
|
"areaKey": "TN",
|
||||||
"chsName": "突尼斯",
|
"chsName": "突尼斯",
|
||||||
|
|
@ -889,7 +1098,12 @@
|
||||||
"enName": "Mauritius",
|
"enName": "Mauritius",
|
||||||
"pyFirst": "M"
|
"pyFirst": "M"
|
||||||
},
|
},
|
||||||
{ "areaKey": "LA", "chsName": "老挝", "enName": "Laos", "pyFirst": "L" },
|
{
|
||||||
|
"areaKey": "LA",
|
||||||
|
"chsName": "老挝",
|
||||||
|
"enName": "Laos",
|
||||||
|
"pyFirst": "L"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "US",
|
"areaKey": "US",
|
||||||
"chsName": "美国",
|
"chsName": "美国",
|
||||||
|
|
@ -1022,14 +1236,24 @@
|
||||||
"enName": "Cyprus",
|
"enName": "Cyprus",
|
||||||
"pyFirst": "S"
|
"pyFirst": "S"
|
||||||
},
|
},
|
||||||
{ "areaKey": "BR", "chsName": "巴西", "enName": "Brazil", "pyFirst": "B" },
|
{
|
||||||
|
"areaKey": "BR",
|
||||||
|
"chsName": "巴西",
|
||||||
|
"enName": "Brazil",
|
||||||
|
"pyFirst": "B"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "LB",
|
"areaKey": "LB",
|
||||||
"chsName": "黎巴嫩",
|
"chsName": "黎巴嫩",
|
||||||
"enName": "Lebanon",
|
"enName": "Lebanon",
|
||||||
"pyFirst": "L"
|
"pyFirst": "L"
|
||||||
},
|
},
|
||||||
{ "areaKey": "IS", "chsName": "冰岛", "enName": "Iceland", "pyFirst": "B" },
|
{
|
||||||
|
"areaKey": "IS",
|
||||||
|
"chsName": "冰岛",
|
||||||
|
"enName": "Iceland",
|
||||||
|
"pyFirst": "B"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "PA",
|
"areaKey": "PA",
|
||||||
"chsName": "巴拿马",
|
"chsName": "巴拿马",
|
||||||
|
|
@ -1054,14 +1278,24 @@
|
||||||
"enName": "New Caledonia",
|
"enName": "New Caledonia",
|
||||||
"pyFirst": "X"
|
"pyFirst": "X"
|
||||||
},
|
},
|
||||||
{ "areaKey": "MT", "chsName": "马尔他", "enName": "Malta", "pyFirst": "M" },
|
{
|
||||||
|
"areaKey": "MT",
|
||||||
|
"chsName": "马尔他",
|
||||||
|
"enName": "Malta",
|
||||||
|
"pyFirst": "M"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "BG",
|
"areaKey": "BG",
|
||||||
"chsName": "保加利亚",
|
"chsName": "保加利亚",
|
||||||
"enName": "Bulgaria",
|
"enName": "Bulgaria",
|
||||||
"pyFirst": "B"
|
"pyFirst": "B"
|
||||||
},
|
},
|
||||||
{ "areaKey": "ES", "chsName": "西班牙", "enName": "Spain", "pyFirst": "X" },
|
{
|
||||||
|
"areaKey": "ES",
|
||||||
|
"chsName": "西班牙",
|
||||||
|
"enName": "Spain",
|
||||||
|
"pyFirst": "X"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "CI",
|
"areaKey": "CI",
|
||||||
"chsName": "象牙海岸",
|
"chsName": "象牙海岸",
|
||||||
|
|
@ -1098,14 +1332,24 @@
|
||||||
"enName": "Georgia",
|
"enName": "Georgia",
|
||||||
"pyFirst": "G"
|
"pyFirst": "G"
|
||||||
},
|
},
|
||||||
{ "areaKey": "SD", "chsName": "苏丹", "enName": "Sudan", "pyFirst": "S" },
|
{
|
||||||
|
"areaKey": "SD",
|
||||||
|
"chsName": "苏丹",
|
||||||
|
"enName": "Sudan",
|
||||||
|
"pyFirst": "S"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "PR",
|
"areaKey": "PR",
|
||||||
"chsName": "波多黎各",
|
"chsName": "波多黎各",
|
||||||
"enName": "Puerto Rico",
|
"enName": "Puerto Rico",
|
||||||
"pyFirst": "B"
|
"pyFirst": "B"
|
||||||
},
|
},
|
||||||
{ "areaKey": "FJ", "chsName": "斐济", "enName": "Fiji", "pyFirst": "F" },
|
{
|
||||||
|
"areaKey": "FJ",
|
||||||
|
"chsName": "斐济",
|
||||||
|
"enName": "Fiji",
|
||||||
|
"pyFirst": "F"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"areaKey": "NL",
|
"areaKey": "NL",
|
||||||
"chsName": "荷兰",
|
"chsName": "荷兰",
|
||||||
|
|
@ -1130,5 +1374,6 @@
|
||||||
"enName": "Turks and Caicos Islands",
|
"enName": "Turks and Caicos Islands",
|
||||||
"pyFirst": "T"
|
"pyFirst": "T"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"currentVersion": 231
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,19 +102,20 @@ async def _get_user_account_info(request: Request) -> Response:
|
||||||
try:
|
try:
|
||||||
user_devid = request.match_info.get("devid", "")
|
user_devid = request.match_info.get("devid", "")
|
||||||
user = user_by_deviceid(user_devid)
|
user = user_by_deviceid(user_devid)
|
||||||
username = f"fusername_{user['userid']}"
|
if user:
|
||||||
return get_success_response(
|
username = f"fusername_{user['userid']}"
|
||||||
{
|
return get_success_response(
|
||||||
"email": "null@null.com",
|
{
|
||||||
"hasMobile": "N",
|
"email": "null@null.com",
|
||||||
"hasPassword": "Y",
|
"hasMobile": "N",
|
||||||
"uid": f"fuid_{user['userid']}",
|
"hasPassword": "Y",
|
||||||
"userName": username,
|
"uid": f"fuid_{user['userid']}",
|
||||||
"obfuscatedMobile": None,
|
"userName": username,
|
||||||
"mobile": None,
|
"obfuscatedMobile": None,
|
||||||
"loginName": username,
|
"mobile": None,
|
||||||
}
|
"loginName": username,
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# Example body
|
# Example body
|
||||||
# {
|
# {
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ class WebServer:
|
||||||
async def _log_all_requests(
|
async def _log_all_requests(
|
||||||
self, request: Request, handler: Handler
|
self, request: Request, handler: Handler
|
||||||
) -> StreamResponse:
|
) -> StreamResponse:
|
||||||
if request._match_info.route.name not in self._EXCLUDE_FROM_LOGGING:
|
if request.match_info.route.name not in self._EXCLUDE_FROM_LOGGING:
|
||||||
to_log = {
|
to_log = {
|
||||||
"request": {
|
"request": {
|
||||||
"route_name": f"{request.match_info.route.name}",
|
"route_name": f"{request.match_info.route.name}",
|
||||||
|
|
|
||||||
1
pylintrc
1
pylintrc
|
|
@ -42,7 +42,6 @@ good-names=i,j,k,ex,_,T,x,y,id
|
||||||
# wrong-import-order - isort guards this
|
# wrong-import-order - isort guards this
|
||||||
disable=
|
disable=
|
||||||
format,
|
format,
|
||||||
abstract-class-little-used,
|
|
||||||
abstract-method,
|
abstract-method,
|
||||||
cyclic-import,
|
cyclic-import,
|
||||||
duplicate-code,
|
duplicate-code,
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,7 @@ def test_user_db():
|
||||||
assert db.check_authcode("testuser", "auth_1234")
|
assert db.check_authcode("testuser", "auth_1234")
|
||||||
# Test that authcode was found for testuser
|
# Test that authcode was found for testuser
|
||||||
|
|
||||||
db.user_revoke_authcode(
|
db.user_revoke_authcode("testuser", "token_1234") # Remove authcode from testuser
|
||||||
"testuser", "token_1234", "auth_1234"
|
|
||||||
) # Remove authcode from testuser
|
|
||||||
assert db.check_authcode("testuser", "auth_1234") == False
|
assert db.check_authcode("testuser", "auth_1234") == False
|
||||||
# Test that authcode was not found for testuser
|
# Test that authcode was not found for testuser
|
||||||
db.user_revoke_token("testuser", "token_1234") # Remove token from testuser
|
db.user_revoke_token("testuser", "token_1234") # Remove token from testuser
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue