Fix http potential errors

Prevent from going further if {server} or {userid} is requested but not filled to avoid 401 errors
This commit is contained in:
angelblue05 2018-09-15 03:16:37 -05:00
parent 223818a807
commit 8d816414b8

View file

@ -53,11 +53,17 @@ class HTTP(object):
def _replace_user_info(self, string):
if self.config['auth.server']:
string = string.decode('utf-8').replace("{server}", self.config['auth.server'])
if '{server}' in string:
if self.config['auth.server']:
string = string.decode('utf-8').replace("{server}", self.config['auth.server'])
else:
raise Exception("Server address not set.")
if self.config['auth.user_id']:
string = string.decode('utf-8').replace("{UserId}", self.config['auth.user_id'])
if '{UserId}'in string:
if self.config['auth.user_id']:
string = string.decode('utf-8').replace("{UserId}", self.config['auth.user_id'])
else:
raise Exception("UserId is not set.")
return string