Moved login-code into a separate function.

This makes it easier to log in users by their token from unittests.
This commit is contained in:
2016-09-08 12:03:51 +02:00
parent 68666f0650
commit 76b0f5fc46
2 changed files with 17 additions and 7 deletions

View File

@@ -33,6 +33,11 @@ class UserClass(flask_login.UserMixin):
class AnonymousUser(flask_login.AnonymousUserMixin):
@property
def objectid(self):
"""Anonymous user has no settable objectid."""
return None
def has_role(self, *roles):
return False
@@ -73,6 +78,13 @@ def config_login_manager(app):
return login_manager
def login_user(oauth_token):
"""Log in the user identified by the given token."""
user = UserClass(oauth_token)
flask_login.login_user(user)
def get_blender_id_oauth_token():
"""Returns a tuple (token, ''), for use with flask_oauthlib."""
return session.get('blender_id_oauth_token')