|
@@ -3423,6 +3423,9 @@ class SingleLoginView(TemplateView):
|
|
elif code_type == '2':
|
|
elif code_type == '2':
|
|
redis_key = '{}_{}_GetDevicePassword'.format(email, uid)
|
|
redis_key = '{}_{}_GetDevicePassword'.format(email, uid)
|
|
email_type = 'get_device_password'
|
|
email_type = 'get_device_password'
|
|
|
|
+ elif code_type == '3':
|
|
|
|
+ redis_key = '{}_GetBackendVerificationCode'.format(email)
|
|
|
|
+ email_type = 'get_backend_verification_code'
|
|
else:
|
|
else:
|
|
return response.json(444)
|
|
return response.json(444)
|
|
|
|
|
|
@@ -3478,6 +3481,9 @@ class SingleLoginView(TemplateView):
|
|
elif code_type == '2':
|
|
elif code_type == '2':
|
|
redis_key = '{}_{}_GetDevicePassword'.format(phone, uid)
|
|
redis_key = '{}_{}_GetDevicePassword'.format(phone, uid)
|
|
temp_msg = 'SMS_479855154' if country_code == '86' else 'SMS_479785146'
|
|
temp_msg = 'SMS_479855154' if country_code == '86' else 'SMS_479785146'
|
|
|
|
+ elif code_type == '3':
|
|
|
|
+ redis_key = '{}_GetBackendVerificationCode'.format(phone)
|
|
|
|
+ temp_msg = 'SMS_151675022' if country_code == '86' else 'SMS_172165867'
|
|
else:
|
|
else:
|
|
return response.json(444)
|
|
return response.json(444)
|
|
|
|
|
|
@@ -5180,3 +5186,70 @@ class ChangeAccountInfoView(View):
|
|
else:
|
|
else:
|
|
ord_user_qs.update(phone=new_phone)
|
|
ord_user_qs.update(phone=new_phone)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class VerifyCodeView(View):
|
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
|
+ request.encoding = 'utf-8'
|
|
|
|
+ operation = kwargs.get('operation')
|
|
|
|
+ request_dict = request.GET
|
|
|
|
+ return self.validation(request_dict, request, operation)
|
|
|
|
+
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
+ request.encoding = 'utf-8'
|
|
|
|
+ operation = kwargs.get('operation')
|
|
|
|
+ request_dict = request.POST
|
|
|
|
+ return self.validation(request_dict, request, operation)
|
|
|
|
+
|
|
|
|
+ def validation(self, request_dict, request, operation):
|
|
|
|
+ language = request_dict.get('lang', 'en')
|
|
|
|
+ response = ResponseObject(language)
|
|
|
|
+ if operation == 'verifyCode':
|
|
|
|
+ return self.verify_code(request_dict, response)
|
|
|
|
+ else:
|
|
|
|
+ return response.json(444)
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def verify_code(request_dict, response):
|
|
|
|
+ """
|
|
|
|
+ 验证邮箱验证码
|
|
|
|
+ @param username: 账户名
|
|
|
|
+ @param code: 用户输入的验证码
|
|
|
|
+ @param response: 响应对象
|
|
|
|
+ @return: 验证结果
|
|
|
|
+ """
|
|
|
|
+ try:
|
|
|
|
+ username = request_dict.get('username')
|
|
|
|
+ code = request_dict.get('code')
|
|
|
|
+
|
|
|
|
+ # 基础参数验证
|
|
|
|
+ if not username or not code:
|
|
|
|
+ return response.json(444)
|
|
|
|
+
|
|
|
|
+ # 生成缓存Key
|
|
|
|
+ redis_key = f'{username}_GetBackendVerificationCode'
|
|
|
|
+ reds = RedisObject()
|
|
|
|
+
|
|
|
|
+ # 获取并验证验证码
|
|
|
|
+ cached_code = reds.get_data(key=redis_key)
|
|
|
|
+ if cached_code is False:
|
|
|
|
+ return response.json(92)
|
|
|
|
+
|
|
|
|
+ # 验证失败次数控制
|
|
|
|
+ if cached_code != code:
|
|
|
|
+ failure_key = f"{redis_key}_failures"
|
|
|
|
+ failures_raw = reds.get_data(key=failure_key)
|
|
|
|
+ failures = int(failures_raw or 0) + 1
|
|
|
|
+ reds.set_data(key=failure_key, val=failures, expire=60)
|
|
|
|
+
|
|
|
|
+ if failures >= 5:
|
|
|
|
+ return response.json(5)
|
|
|
|
+
|
|
|
|
+ return response.json(121)
|
|
|
|
+
|
|
|
|
+ # 验证成功,清理缓存
|
|
|
|
+ reds.del_data(redis_key)
|
|
|
|
+ reds.del_data(f"{redis_key}_failures")
|
|
|
|
+ return response.json(0)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|