chg: [Sensor registration] handle empty key

gallypette-patch-1
Terrtia 2019-09-24 14:35:55 +02:00
parent 61043d81aa
commit 648e406c54
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
1 changed files with 9 additions and 0 deletions

View File

@ -5,6 +5,8 @@ import os
import uuid
import redis
from Flask import escape
host_redis_metadata = os.getenv('D4_REDIS_METADATA_HOST', "localhost")
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)):
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)
return res