|
@@ -3416,7 +3416,6 @@ class generatePictureCodeView(TemplateView):
|
|
|
return HttpResponse(data)
|
|
|
|
|
|
|
|
|
-# 图片验证码校验注册
|
|
|
class Image_Code_RegisterView(TemplateView):
|
|
|
@method_decorator(csrf_exempt)
|
|
|
def dispatch(self, *args, **kwargs):
|
|
@@ -3432,23 +3431,37 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
request_dict = request.GET
|
|
|
return self.validates(request_dict)
|
|
|
|
|
|
- # 检测验证码,并注册
|
|
|
def validates(self, request_dict):
|
|
|
- print("__________request_dict:%s" % request_dict)
|
|
|
+ """
|
|
|
+ 图片验证码注册
|
|
|
+ @param request_dict: 请求数据
|
|
|
+ @request_dict userEmail: 邮箱
|
|
|
+ @request_dict userPwd: 密码
|
|
|
+ @request_dict imageCodeId: 图片验证码id
|
|
|
+ @request_dict valid_code: 验证码
|
|
|
+ @request_dict unique: 手机唯一标识
|
|
|
+ @request_dict number: 国家id号
|
|
|
+ @request_dict region_status: 地区选择状态
|
|
|
+ @request_dict lang: 语言
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
userEmail = request_dict.get('userEmail', None)
|
|
|
password = request_dict.get('userPwd', None)
|
|
|
- lang = request_dict.get('lang', None)
|
|
|
- # 前端传进来的uuid
|
|
|
imageCodeId = request_dict.get('imageCodeId', None)
|
|
|
- # 页面输入的验证码
|
|
|
- response = ResponseObject(lang)
|
|
|
valid_code = request_dict.get('id_v_code', None)
|
|
|
unique = request_dict.get('unique', None)
|
|
|
number = request_dict.get('number', None)
|
|
|
- if unique:
|
|
|
- delete_local_account(unique)
|
|
|
+ region_status = request_dict.get('region_status', None)
|
|
|
+ lang = request_dict.get('lang', None)
|
|
|
+ response = ResponseObject(lang)
|
|
|
+
|
|
|
if not all([userEmail, password, lang, imageCodeId, valid_code]):
|
|
|
return response.json(444)
|
|
|
+
|
|
|
+ if unique:
|
|
|
+ delete_local_account(unique)
|
|
|
+ region_status = int(region_status) if region_status else 0
|
|
|
+
|
|
|
try:
|
|
|
for i in range(1, 4):
|
|
|
if i == 1:
|
|
@@ -3463,7 +3476,6 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
password = base64.b64decode(password)
|
|
|
password = password.decode('utf-8')
|
|
|
password = password[3:-3]
|
|
|
- print("password%s" % password)
|
|
|
except Exception as e:
|
|
|
return response.json(111)
|
|
|
try:
|
|
@@ -3480,13 +3492,13 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
valid_code = base64.b64decode(valid_code)
|
|
|
valid_code = valid_code.decode('utf-8')
|
|
|
valid_code = valid_code[3:-3]
|
|
|
- print("valid_code:%s" % valid_code)
|
|
|
except Exception as e:
|
|
|
return response.json(121)
|
|
|
if not userEmail:
|
|
|
return response.json(105)
|
|
|
if not password:
|
|
|
return response.json(109)
|
|
|
+
|
|
|
userEmail = userEmail.strip()
|
|
|
password = password.strip()
|
|
|
# 注释
|
|
@@ -3494,13 +3506,10 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
emailValid = Device_User.objects.filter(userEmail=userEmail)
|
|
|
if emailValid:
|
|
|
return response.json(103)
|
|
|
- # 根据uuid拼接的key
|
|
|
- image_code_key = "image_code_%s" % imageCodeId
|
|
|
+
|
|
|
# 判断验证码是否过期
|
|
|
- if image_code_key is None:
|
|
|
- return response.json(120)
|
|
|
+ image_code_key = 'image_code_%s' % imageCodeId
|
|
|
redisObj = RedisObject(db=6)
|
|
|
- # redis里面的验证码
|
|
|
redis_image_code = redisObj.get_data(key=image_code_key)
|
|
|
# 验证用户输入的验证码和redis中的验证码
|
|
|
if redis_image_code is False or valid_code.lower() != redis_image_code.lower():
|
|
@@ -3511,7 +3520,8 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
email_qs = Device_User.objects.filter(Q(userEmail=userEmail) | Q(username=userEmail))
|
|
|
if email_qs:
|
|
|
return response.json(103)
|
|
|
- # #存用户名和密码
|
|
|
+
|
|
|
+ # 创建用户
|
|
|
create_data = {
|
|
|
"username": username,
|
|
|
"NickName": username,
|
|
@@ -3520,17 +3530,18 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
"userID": CommonService.getUserID(μs=False, setOTAID=True),
|
|
|
"is_active": True,
|
|
|
"user_isValid": True,
|
|
|
+ "region_status": region_status
|
|
|
}
|
|
|
if number:
|
|
|
create_data["region_country"] = number
|
|
|
- users = Device_User.objects.create(**create_data)
|
|
|
+ Device_User.objects.create(**create_data)
|
|
|
return self.do_login(email_qs, response)
|
|
|
|
|
|
- def do_login(self, user_qs, response):
|
|
|
+ @staticmethod
|
|
|
+ def do_login(user_qs, response):
|
|
|
now_time = datetime.datetime.utcnow().replace(tzinfo=utc).astimezone(utc)
|
|
|
user_qs.update(last_login=now_time, online=True)
|
|
|
userID = user_qs[0].userID
|
|
|
- print('userID' + userID)
|
|
|
tko = TokenObject()
|
|
|
user_list = user_qs.values("NickName", "userIconUrl", "userIconPath", "username", "userEmail", "phone")
|
|
|
res = tko.generate(data={'userID': userID, 'lang': response.lang, 'user': user_list[0]["username"]})
|
|
@@ -3552,7 +3563,6 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
res['username'] = user_list[0]["username"] if user_list[0]["username"] is not None else ''
|
|
|
res['userEmail'] = user_list[0]["userEmail"] if user_list[0]["userEmail"] is not None else ''
|
|
|
res['phone'] = user_list[0]["phone"] if user_list[0]["phone"] is not None else ''
|
|
|
- print(res)
|
|
|
return response.json(0, res)
|
|
|
|
|
|
|