When BlenderID is unreachable, log an error and handle as not logged in.

This commit is contained in:
Sybren A. Stüvel 2016-03-31 11:16:27 +02:00
parent 6e04fa072b
commit 91d6175472

View File

@ -32,12 +32,14 @@ def validate(token):
log.debug("Validating token %s", token) log.debug("Validating token %s", token)
payload = dict( payload = dict(
token=token) token=token)
url = "{0}/u/validate_token".format(blender_id_endpoint())
try: try:
url = "{0}/u/validate_token".format(blender_id_endpoint())
log.debug('POSTing to %r', url) log.debug('POSTing to %r', url)
r = requests.post(url, data=payload) r = requests.post(url, data=payload)
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
raise e log.error('Connection error trying to POST to %s, handling as invalid token.', url)
return None
if r.status_code != 200: if r.status_code != 200:
log.info('HTTP error %i validating token: %s', r.status_code, r.content) log.info('HTTP error %i validating token: %s', r.status_code, r.content)