Use Blender ID subclient-specific token to find the user.

TODO: also store expiry timestamp
TODO: allow multiple subclient-specific tokens per user
This commit is contained in:
2016-04-12 16:53:27 +02:00
parent bd8e0e56a4
commit e898fe0315
2 changed files with 29 additions and 0 deletions

View File

@@ -90,12 +90,15 @@ def validate_subclient_token(user_id, scst):
def find_user_in_db(user_id, scst, email, full_name):
"""Find the user in our database, creating/updating it where needed."""
users = current_app.data.driver.db['users']
query = {'auth': {'$elemMatch': {'user_id': user_id, 'provider': 'blender-id'}}}
log.debug('Querying: %s', query)
db_user = users.find_one(query)
# TODO: include token expiry in database.
if db_user:
log.debug('User %r already in our database, updating with info from Blender ID.', user_id)
db_user['full_name'] = full_name