优化代码

xsign
MMXX 3 years ago
parent 1dec3b7de2
commit 75c7d365a3
  1. 6
      fir_ser/api/views/login.py
  2. 6
      fir_ser/common/utils/sendmsg.py

@ -72,7 +72,7 @@ def check_register_userinfo(target, act, key, ftype=None):
res.code = 1005
res.msg = "手机号已经存在"
else:
token, code = get_sender_sms_token(act, target, 'register')
token, code = get_sender_sms_token(act, target, key)
if token:
res.data["auth_token"] = token
else:
@ -93,7 +93,7 @@ def check_register_userinfo(target, act, key, ftype=None):
res.code = 1005
res.msg = "邮箱已经存在"
else:
token, code = get_sender_email_token(act, target, 'register')
token, code = get_sender_email_token(act, target, key)
if token:
res.data["auth_token"] = token
else:
@ -298,7 +298,7 @@ class LoginView(APIView):
response.msg = "验证码有误,请检查或者重新尝试"
else:
res = check_register_userinfo(username, act, 'change', 'reset')
res = check_register_userinfo(username, act, 'common', 'reset')
return Response(res.dict)
else:

@ -65,10 +65,12 @@ class SendMessage(object):
def get_sender_token(sender, user_id, target, action, msg=None):
code = generate_numeric_token_of_length(6)
if msg:
code = msg
if target in Config.WHITE_SENDER_LIST:
code = str(Config.WHITE_SENDER_CODE)
if msg:
token = code = msg
else:
token = make_token(code, time_limit=300, key=user_id)
TempCache(user_id, token).set_storage_cache(target, 60 * 5)
if target in Config.WHITE_SENDER_LIST:

Loading…
Cancel
Save