s/_token/token/

This commit is contained in:
Fabio Manganiello 2018-07-08 22:00:28 +02:00
parent 2647bd3881
commit e1ead3c25f
1 changed files with 2 additions and 6 deletions

View File

@ -46,7 +46,7 @@ class HttpBackend(Backend):
Note that if you set up a main token, it will be required for any HTTP Note that if you set up a main token, it will be required for any HTTP
interaction - either as ``X-Token`` HTTP header, on the query string interaction - either as ``X-Token`` HTTP header, on the query string
(attribute name: ``token``), as part of the JSON payload root (attribute (attribute name: ``token``), as part of the JSON payload root (attribute
name: ``_token``), or via HTTP basic auth (any username works). name: ``token``), or via HTTP basic auth (any username works).
Requires: Requires:
@ -201,7 +201,7 @@ class HttpBackend(Backend):
else: else:
try: try:
args = json.loads(http_request.data.decode('utf-8')) args = json.loads(http_request.data.decode('utf-8'))
user_token = args.get('_token') user_token = args.get('token')
except: except:
pass pass
@ -222,12 +222,8 @@ class HttpBackend(Backend):
@app.route('/execute', methods=['POST']) @app.route('/execute', methods=['POST'])
def execute(): def execute():
""" Endpoint to execute commands """ """ Endpoint to execute commands """
args = json.loads(http_request.data.decode('utf-8'))
if not self._authentication_ok(): return self._authenticate() if not self._authentication_ok(): return self._authenticate()
if '_token' in args:
del args['_token']
args = json.loads(http_request.data.decode('utf-8')) args = json.loads(http_request.data.decode('utf-8'))
msg = Message.build(args) msg = Message.build(args)
self.logger.info('Received message on the HTTP backend: {}'.format(msg)) self.logger.info('Received message on the HTTP backend: {}'.format(msg))