forked from platypush/platypush
Fixed LGTM warnings
This commit is contained in:
parent
8d26c8634d
commit
5966566d54
2 changed files with 16 additions and 10 deletions
|
@ -16,12 +16,14 @@ __routes__ = [
|
||||||
@execute.route('/execute', methods=['POST'])
|
@execute.route('/execute', methods=['POST'])
|
||||||
@authenticate()
|
@authenticate()
|
||||||
def execute():
|
def execute():
|
||||||
""" Endpoint to execute commands """
|
"""Endpoint to execute commands"""
|
||||||
try:
|
try:
|
||||||
msg = json.loads(request.data.decode('utf-8'))
|
msg = json.loads(request.data.decode('utf-8'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger().error('Unable to parse JSON from request {}: {}'.format(request.data, str(e)))
|
logger().error(
|
||||||
return abort(400, str(e))
|
'Unable to parse JSON from request {}: {}'.format(request.data, str(e))
|
||||||
|
)
|
||||||
|
abort(400, str(e))
|
||||||
|
|
||||||
logger().info('Received message on the HTTP backend: {}'.format(msg))
|
logger().info('Received message on the HTTP backend: {}'.format(msg))
|
||||||
|
|
||||||
|
@ -29,8 +31,10 @@ def execute():
|
||||||
response = send_message(msg)
|
response = send_message(msg)
|
||||||
return Response(str(response or {}), mimetype='application/json')
|
return Response(str(response or {}), mimetype='application/json')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger().error('Error while running HTTP action: {}. Request: {}'.format(str(e), msg))
|
logger().error(
|
||||||
return abort(500, str(e))
|
'Error while running HTTP action: {}. Request: {}'.format(str(e), msg)
|
||||||
|
)
|
||||||
|
abort(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
|
@ -13,17 +13,19 @@ __routes__ = [
|
||||||
|
|
||||||
@logout.route('/logout', methods=['GET', 'POST'])
|
@logout.route('/logout', methods=['GET', 'POST'])
|
||||||
def logout():
|
def logout():
|
||||||
""" Logout page """
|
"""Logout page"""
|
||||||
user_manager = UserManager()
|
user_manager = UserManager()
|
||||||
redirect_page = request.args.get('redirect', request.headers.get('Referer', '/login'))
|
redirect_page = request.args.get(
|
||||||
|
'redirect', request.headers.get('Referer', '/login')
|
||||||
|
)
|
||||||
session_token = request.cookies.get('session_token')
|
session_token = request.cookies.get('session_token')
|
||||||
|
|
||||||
if not session_token:
|
if not session_token:
|
||||||
return abort(417, 'Not logged in')
|
abort(417, 'Not logged in')
|
||||||
|
|
||||||
user, session = user_manager.authenticate_user_session(session_token)
|
user, _ = user_manager.authenticate_user_session(session_token)
|
||||||
if not user:
|
if not user:
|
||||||
return abort(403, 'Invalid session token')
|
abort(403, 'Invalid session token')
|
||||||
|
|
||||||
redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||||
response = make_response(redirect_target)
|
response = make_response(redirect_target)
|
||||||
|
|
Loading…
Reference in a new issue