From 75c7d365a39cf87c663de779ef442a875a16e99a Mon Sep 17 00:00:00 2001 From: MMXX Date: Thu, 10 Mar 2022 14:41:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/views/login.py | 6 +++--- fir_ser/common/utils/sendmsg.py | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fir_ser/api/views/login.py b/fir_ser/api/views/login.py index 6e5c673..f5e3bd7 100644 --- a/fir_ser/api/views/login.py +++ b/fir_ser/api/views/login.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: diff --git a/fir_ser/common/utils/sendmsg.py b/fir_ser/common/utils/sendmsg.py index 69b95d7..943b15c 100644 --- a/fir_ser/common/utils/sendmsg.py +++ b/fir_ser/common/utils/sendmsg.py @@ -65,12 +65,14 @@ 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) - token = make_token(code, time_limit=300, key=user_id) - TempCache(user_id, token).set_storage_cache(target, 60 * 5) + 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: return token, code if action in ('change', 'password', 'register', 'login', 'common'):