Commit e1ab4310 authored by ZZH's avatar ZZH

fix log mutil lang 2024-06-19

parent 50a5b41e
......@@ -419,7 +419,7 @@ PRODUCT_INFOS = {
},
7: {
"name": "识电U新版",
"url": SETTING.shidianu_new_url,
"url": SETTING.comp_energy_url,
"img_url": f"{SETTING.download_img_url}/image/new-shidianu.png",
"sort_num": 31
},
......@@ -884,7 +884,27 @@ LOG_IN_TIPS = {
"unbind_wechat_suc": {
"zh_CN": "解除微信绑定成功",
"en_US": "Unbinding WeChat has been successful",
"de_DE": "WeChat- binding erfolgreich gelöst "
"de_DE": "WeChat- binding erfolgreich gelöst"
},
"wechat_bind_suc": {
"zh_CN": "微信绑定成功",
"en_US": "WeChat binding successful",
"de_DE": "WeChat-Bindung erfolgreich"
},
"wechat_bind_fail": {
"zh_CN": "微信绑定失败",
"en_US": "WeChat binding failed",
"de_DE": "Die WeChat-Bindung ist fehlgeschlagen"
},
"wechat_bound": {
"zh_CN": "该微信号已经被绑定",
"en_US": "This WeChat ID has been bound",
"de_DE": "Diese WeChat-ID wurde gebunden"
},
"phone_no_usable": {
"zh_CN": "该手机号码可用",
"en_US": "The phone number is available",
"de_DE": "Die Handynummer ist verfügbar"
},
"phone_no_reg_dea": {
"zh_CN": "手机号未注册或已注销",
......@@ -901,9 +921,45 @@ LOG_IN_TIPS = {
"en_US": "succeed",
"de_DE": "Erfolg"
},
"fail": {
"zh_CN": "失败",
"en_US": "fail",
"de_DE": "scheitern"
},
"direct_info_page": {
"zh_CN": "跳转填写页面",
"en_US": "Skip fill page",
"de_DE": "Springen Sie zur Seite zum Ausfüllen von Informationen"
},
"miss_req_param": {
"zh_CN": "缺少必传参数",
"en_US": "Missing required parameters",
"de_DE": "Erforderliche Parameter fehlen"
},
"update_suc": {
"zh_CN": "修改成功",
"en_US": "Successfully modified",
"de_DE": "Erfolgreich geändert"
},
"vfy_pass": {
"zh_CN": "验证通过",
"en_US": "Verification passed",
"de_DE": "Verifizierung bestanden"
},
"miss_param": {
"zh_CN": "缺少参数",
"en_US": "Missing parameters",
"de_DE": "Fehlende Parameter"
},
"logout_suc": {
"zh_CN": "注销成功",
"en_US": "Logout successful",
"de_DE": "Abmeldung erfolgreich"
},
"account_no_auth": {
"zh_CN": "当前账号无权限,请联系管理人员",
"en_US": "The current account does not have permission, please contact the administrator",
"de_DE": "Für das aktuelle Konto ist keine Berechtigung vorhanden. Bitte wenden Sie sich an den Administrator"
},
}
......@@ -70,7 +70,7 @@ async def app_login(args, host):
return 401, {"code": 40001, "data": None, "message": str(e)}
async def web_login(args, host):
async def web_login(args, host, lang):
"""web登录"""
# 1. 准备转发给auth服务的参数
request_body = {
......@@ -88,17 +88,23 @@ async def web_login(args, host):
request_body,
timeout=50,
)
log.info(
f"web_login request auth_url resp_str={resp_str} status={status}")
log.info(f"web_login request auth_url rsp={resp_str} status={status}")
resp = json.loads(resp_str)
if status == 301:
return 301, {"code": 30001, "data": {"wechat_id":
resp['reasons'][0]},
"message": "跳转填写页面"}
# 跳转填写页面
tip = load_login_tips("direct_info_page", lang)
return 301, {"code": 30001,
"data": {"wechat_id": resp['reasons'][0]},
"message": tip}
elif status == 200:
return 200, {"code": 200, "data": resp, "message": "成功"}
# 成功
tip = load_login_tips("succeed", lang)
return 200, {"code": 200, "data": resp, "message": tip}
else:
return 401, {"code": 40001, "data": resp, "message": "失败"}
# 失败
tip = load_login_tips("fail", lang)
return 401, {"code": 40001, "data": resp, "message": tip}
except Exception as e:
log.exception(e)
return 401, {"code": 401, "data": None, "message": str(e)}
......@@ -212,9 +218,8 @@ async def validation_login(args, host, lang):
user = await user_by_phone_number(phone)
if not user:
# 不存在用户,通知前端跳转填写信息页面
# 跳转填写页面
tip = load_login_tips("direct_info_page", lang)
# 当前账号无权限,请联系管理人员
tip = load_login_tips("account_no_auth", lang)
return 301, {"code": 30001, "data": None, "message": tip}
# 1. 准备转发给auth服务的参数
......
......@@ -49,7 +49,7 @@ class AuthView(HTTPMethodView):
# 自定义状态码
resp_body["code"] = 40001
elif client_name == "web":
status_code, resp_body = await web_login(args, host)
status_code, resp_body = await web_login(args, host, lang)
if status_code == 401:
resp_body["code"] = 40001
elif client_name == "script":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment