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'):