mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-16 06:15:09 -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'],
|
'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
|
# set the original call_dispatcher as the local _call_dispatcher
|
||||||
_call_dispatcher = self.call_dispatcher
|
_call_dispatcher = self.call_dispatcher
|
||||||
# if profile was set wrap "_call_dispatcher" in the profile function
|
# if profile was set wrap "_call_dispatcher" in the profile function
|
||||||
@ -115,7 +123,10 @@ class ApiHandler(RequestHandler):
|
|||||||
else:
|
else:
|
||||||
outputCallback = outputCallbackDict['default']
|
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):
|
def _out_as_json(self, dict):
|
||||||
self.set_header("Content-Type", "application/json;charset=UTF-8'")
|
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 args: '" + str(args) + "'", logger.DEBUG)
|
||||||
logger.log(u"API :: all kwargs: '" + str(kwargs) + "'", logger.DEBUG)
|
logger.log(u"API :: all kwargs: '" + str(kwargs) + "'", logger.DEBUG)
|
||||||
# logger.log(u"API :: dateFormat: '" + str(dateFormat) + "'", logger.DEBUG)
|
|
||||||
|
|
||||||
cmds = None
|
cmds = None
|
||||||
if args:
|
if args:
|
||||||
|
@ -137,11 +137,13 @@ class BaseHandler(RequestHandler):
|
|||||||
index_url = sickbeard.WEB_ROOT
|
index_url = sickbeard.WEB_ROOT
|
||||||
url = self.request.uri[len(index_url):]
|
url = self.request.uri[len(index_url):]
|
||||||
|
|
||||||
if url[:3] != 'api':
|
if url[1:4] != 'api':
|
||||||
return self.redirect(url)
|
return self.redirect(url)
|
||||||
else:
|
else:
|
||||||
self.write('Wrong API key used')
|
if url.endswith('/'):
|
||||||
self.finish()
|
self.finish('Wrong API key used')
|
||||||
|
else:
|
||||||
|
return self.redirect(url + '/')
|
||||||
|
|
||||||
elif self.settings.get("debug") and "exc_info" in kwargs:
|
elif self.settings.get("debug") and "exc_info" in kwargs:
|
||||||
exc_info = kwargs["exc_info"]
|
exc_info = kwargs["exc_info"]
|
||||||
@ -216,8 +218,7 @@ class WebHandler(BaseHandler):
|
|||||||
except:
|
except:
|
||||||
results = str(results)
|
results = str(results)
|
||||||
|
|
||||||
self.write(results)
|
self.finish(results)
|
||||||
self.finish()
|
|
||||||
except:
|
except:
|
||||||
logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG)
|
logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG)
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user