mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-05 17:05:03 -05:00
Fixed issue #1105
This commit is contained in:
parent
de24e52be6
commit
467c42747f
@ -86,6 +86,14 @@ class ApiHandler(RequestHandler):
|
||||
'image': lambda x: x['image'],
|
||||
}
|
||||
|
||||
if sickbeard.USE_API is not True:
|
||||
accessMsg = u"API :: " + self.request.remote_ip + " - SB API Disabled. ACCESS DENIED"
|
||||
logger.log(accessMsg, logger.WARNING)
|
||||
return self.finish(outputCallbackDict['default'](_responds(RESULT_DENIED, msg=accessMsg)))
|
||||
else:
|
||||
accessMsg = u"API :: " + self.request.remote_ip + " - gave correct API KEY. ACCESS GRANTED"
|
||||
logger.log(accessMsg, logger.DEBUG)
|
||||
|
||||
# set the original call_dispatcher as the local _call_dispatcher
|
||||
_call_dispatcher = self.call_dispatcher
|
||||
# if profile was set wrap "_call_dispatcher" in the profile function
|
||||
@ -115,7 +123,10 @@ class ApiHandler(RequestHandler):
|
||||
else:
|
||||
outputCallback = outputCallbackDict['default']
|
||||
|
||||
return self.write(outputCallback(outDict))
|
||||
if not len(outDict) > 0:
|
||||
outDict = _responds(RESULT_SUCCESS, msg=accessMsg)
|
||||
|
||||
return self.finish(outputCallback(outDict))
|
||||
|
||||
def _out_as_json(self, dict):
|
||||
self.set_header("Content-Type", "application/json;charset=UTF-8'")
|
||||
@ -139,7 +150,6 @@ class ApiHandler(RequestHandler):
|
||||
"""
|
||||
logger.log(u"API :: all args: '" + str(args) + "'", logger.DEBUG)
|
||||
logger.log(u"API :: all kwargs: '" + str(kwargs) + "'", logger.DEBUG)
|
||||
# logger.log(u"API :: dateFormat: '" + str(dateFormat) + "'", logger.DEBUG)
|
||||
|
||||
cmds = None
|
||||
if args:
|
||||
|
@ -137,11 +137,13 @@ class BaseHandler(RequestHandler):
|
||||
index_url = sickbeard.WEB_ROOT
|
||||
url = self.request.uri[len(index_url):]
|
||||
|
||||
if url[:3] != 'api':
|
||||
if url[1:4] != 'api':
|
||||
return self.redirect(url)
|
||||
else:
|
||||
self.write('Wrong API key used')
|
||||
self.finish()
|
||||
if url.endswith('/'):
|
||||
self.finish('Wrong API key used')
|
||||
else:
|
||||
return self.redirect(url + '/')
|
||||
|
||||
elif self.settings.get("debug") and "exc_info" in kwargs:
|
||||
exc_info = kwargs["exc_info"]
|
||||
@ -216,8 +218,7 @@ class WebHandler(BaseHandler):
|
||||
except:
|
||||
results = str(results)
|
||||
|
||||
self.write(results)
|
||||
self.finish()
|
||||
self.finish(results)
|
||||
except:
|
||||
logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG)
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user