mirror of https://github.com/D4-project/d4-core
chg: [Sensor registration] handle empty key
parent
61043d81aa
commit
648e406c54
|
@ -5,6 +5,8 @@ import os
|
||||||
import uuid
|
import uuid
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
|
from Flask import escape
|
||||||
|
|
||||||
host_redis_metadata = os.getenv('D4_REDIS_METADATA_HOST', "localhost")
|
host_redis_metadata = os.getenv('D4_REDIS_METADATA_HOST', "localhost")
|
||||||
port_redis_metadata = int(os.getenv('D4_REDIS_METADATA_PORT', 6380))
|
port_redis_metadata = int(os.getenv('D4_REDIS_METADATA_PORT', 6380))
|
||||||
|
|
||||||
|
@ -34,6 +36,13 @@ def register_sensor(req_dict):
|
||||||
if r_serv_db.exists('metadata_uuid:{}'.format(sensor_uuid)):
|
if r_serv_db.exists('metadata_uuid:{}'.format(sensor_uuid)):
|
||||||
return ({"status": "error", "reason": "Sensor already registred"}, 409)
|
return ({"status": "error", "reason": "Sensor already registred"}, 409)
|
||||||
|
|
||||||
|
# hmac key
|
||||||
|
if not hmac_key:
|
||||||
|
return ({"status": "error", "reason": "Mandatory parameter(s) not provided"}, 400)
|
||||||
|
else:
|
||||||
|
hmac_key = escape(hmac_key)
|
||||||
|
|
||||||
|
|
||||||
res = _register_sensor(sensor_uuid, hmac_key, user_id=user_id, description=None)
|
res = _register_sensor(sensor_uuid, hmac_key, user_id=user_id, description=None)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue