get_blender_id_oauth_token() now consistently returns a str

Before it could return either of str, tuple, or None.
This commit is contained in:
Sybren A. Stüvel 2017-10-17 12:16:56 +02:00
parent a897282400
commit 88ffd64706
2 changed files with 5 additions and 7 deletions

View File

@ -126,8 +126,6 @@ def validate_token():
from pillar import auth
token = auth.get_blender_id_oauth_token()
if token and isinstance(token, (tuple, list)):
token = token[0]
oauth_subclient = None
if not token:

View File

@ -212,8 +212,8 @@ def login_user(oauth_token: str, *, load_from_db=False):
g.current_user = user
def get_blender_id_oauth_token():
"""Returns a tuple (token, ''), for use with flask_oauthlib."""
def get_blender_id_oauth_token() -> str:
"""Returns the Blender ID auth token, or an empty string if there is none."""
from flask import request
@ -221,10 +221,10 @@ def get_blender_id_oauth_token():
if token:
return token
if request.authorization:
return request.authorization.username, ''
if request.authorization and request.authorization.username:
return request.authorization.username
return None
return ''
def get_current_user() -> UserClass: