Commit 722200d4 authored by ZZH's avatar ZZH

fix login mutil lang 2024-06-19

parent e1ab4310
...@@ -4,12 +4,25 @@ DATE:2024/5/30 11:34 ...@@ -4,12 +4,25 @@ DATE:2024/5/30 11:34
""" """
from pot_libs.logger import log from pot_libs.logger import log
from unify_api.modules.users.procedures.jwt_user import jwt_user
from unify_api.modules.common.dao.common_dao import load_user_lang
from unify_api.constants import ( from unify_api.constants import (
E_TYPE_MSG_LANG, PHASE_LINE_LANG, E_TYPE_NAME_LANG, LOG_IN_TIPS, E_TYPE_MSG_LANG, PHASE_LINE_LANG, E_TYPE_NAME_LANG, LOG_IN_TIPS,
PRODUCT_INFOS, PRODUCT_NAME PRODUCT_INFOS, PRODUCT_NAME
) )
async def parse_user_lang(request):
lang = "zh_CN"
try:
lang = request.args.get("lang")
except Exception as e:
user_id = jwt_user(request)
lang = await load_user_lang(user_id)
finally:
return lang
def load_event_msg(e_type, event_param, lang): def load_event_msg(e_type, event_param, lang):
if not event_param: if not event_param:
return "" return ""
......
...@@ -22,6 +22,7 @@ from unify_api.modules.common.procedures.multi_lang import ( ...@@ -22,6 +22,7 @@ from unify_api.modules.common.procedures.multi_lang import (
) )
from unify_api.modules.users.procedures.jwt_user import auth_phone_verify, \ from unify_api.modules.users.procedures.jwt_user import auth_phone_verify, \
check_password check_password
from unify_api.modules.common.procedures.multi_lang import parse_user_lang
AUTH_EXP = 300 # redis缓存时间 AUTH_EXP = 300 # redis缓存时间
VALIDATION_EXP = 60 # 发送验证码间隔时间 VALIDATION_EXP = 60 # 发送验证码间隔时间
...@@ -96,8 +97,7 @@ async def get_user_info(request) -> UserInfoResponse: ...@@ -96,8 +97,7 @@ async def get_user_info(request) -> UserInfoResponse:
@summary("发送手机验证码") @summary("发送手机验证码")
async def get_send_sms(request): async def get_send_sms(request):
phone = request.args.get("phone") phone = request.args.get("phone")
user_id = jwt_user(request) lang = await parse_user_lang(request)
lang = await load_user_lang(user_id)
if re.match(r'^1[3-9]\d{9}$', phone): if re.match(r'^1[3-9]\d{9}$', phone):
send_flag = await RedisUtils().get(f"sms:send_sms_flag_{phone}") send_flag = await RedisUtils().get(f"sms:send_sms_flag_{phone}")
if send_flag: if send_flag:
......
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