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
|
@ -20,8 +20,10 @@ def execute():
|
|||
try:
|
||||
msg = json.loads(request.data.decode('utf-8'))
|
||||
except Exception as e:
|
||||
logger().error('Unable to parse JSON from request {}: {}'.format(request.data, str(e)))
|
||||
return abort(400, str(e))
|
||||
logger().error(
|
||||
'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))
|
||||
|
||||
|
@ -29,8 +31,10 @@ def execute():
|
|||
response = send_message(msg)
|
||||
return Response(str(response or {}), mimetype='application/json')
|
||||
except Exception as e:
|
||||
logger().error('Error while running HTTP action: {}. Request: {}'.format(str(e), msg))
|
||||
return abort(500, str(e))
|
||||
logger().error(
|
||||
'Error while running HTTP action: {}. Request: {}'.format(str(e), msg)
|
||||
)
|
||||
abort(500, str(e))
|
||||
|
||||
|
||||
# vim:sw=4:ts=4:et:
|
||||
|
|
|
@ -15,15 +15,17 @@ __routes__ = [
|
|||
def logout():
|
||||
"""Logout page"""
|
||||
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')
|
||||
|
||||
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:
|
||||
return abort(403, 'Invalid session token')
|
||||
abort(403, 'Invalid session token')
|
||||
|
||||
redirect_target = redirect(redirect_page, 302) # lgtm [py/url-redirection]
|
||||
response = make_response(redirect_target)
|
||||
|
|
Loading…
Reference in a new issue