|
@@ -74,13 +74,9 @@ class IotCoreView(View):
|
|
|
if not all([token, time_stamp, device_version, language]):
|
|
|
return response.json(444, {'param': 'token, uid_code, time_stamp, device_version, language'})
|
|
|
|
|
|
- # token时间戳校验
|
|
|
- token = int(CommonService.decode_data(token))
|
|
|
- time_stamp = int(time_stamp)
|
|
|
- now_time = int(time.time())
|
|
|
- distance = now_time - time_stamp
|
|
|
- if token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
|
- return response.json(404)
|
|
|
+ # 时间戳token校验
|
|
|
+ if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
|
|
|
if not uid:
|
|
|
# 使用序列号
|
|
@@ -120,7 +116,7 @@ class IotCoreView(View):
|
|
|
|
|
|
iotClient = IOTClient(region_id)
|
|
|
res = iotClient.create_keys_and_certificate(ThingNameSuffix, thingGroup, response)
|
|
|
- token_iot_number = hashlib.md5((str(uuid.uuid1()) + str(now_time)).encode('utf-8')).hexdigest()
|
|
|
+ token_iot_number = hashlib.md5((str(uuid.uuid1()) + str(int(time.time()))).encode('utf-8')).hexdigest()
|
|
|
|
|
|
iotdeviceInfoModel.objects.create(uid=uid,
|
|
|
serial_number=serial,
|
|
@@ -164,13 +160,9 @@ class IotCoreView(View):
|
|
|
if not all([token, language, time_stamp, device_version]):
|
|
|
return response.json(444, {'param: token, language, time_stamp, device_version'})
|
|
|
|
|
|
- # 封装token认证
|
|
|
- token = int(CommonService.decode_data(token))
|
|
|
- time_stamp = int(time_stamp)
|
|
|
- now_time = int(time.time())
|
|
|
- distance = now_time - time_stamp
|
|
|
- if token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
|
- return response.json(404)
|
|
|
+ # 时间戳token校验
|
|
|
+ if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
|
|
|
ip = CommonService.get_ip_address(request)
|
|
|
region_id = Device_Region().get_device_region(ip)
|