Prevent crash when session['blender_id_oauth_token'] doesn't exist

This commit is contained in:
Sybren A. Stüvel 2018-01-03 12:19:03 +01:00
parent 1c6599fc30
commit fdb9970792

View File

@ -217,7 +217,11 @@ def fetch_blenderid_user() -> dict:
my_log.debug('Fetching user info from %s', bid_url)
credentials = current_app.config['OAUTH_CREDENTIALS']['blender-id']
oauth_token = session['blender_id_oauth_token']
oauth_token = session.get('blender_id_oauth_token')
if not oauth_token:
my_log.warning('no Blender ID oauth token found in user session')
return {}
assert isinstance(oauth_token, str), f'oauth token must be str, not {type(oauth_token)}'
oauth_session = OAuth2Session(