From fdb9154b855ed2c3b0bbefd7bdb8d280d4463c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 12 May 2017 13:40:59 +0200 Subject: [PATCH] Allow login_user() to load the user from the database This makes it easier to properly log someone in from a unit test. --- pillar/auth/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pillar/auth/__init__.py b/pillar/auth/__init__.py index 45aad8a9..aa648694 100644 --- a/pillar/auth/__init__.py +++ b/pillar/auth/__init__.py @@ -79,10 +79,13 @@ def config_login_manager(app): return login_manager -def login_user(oauth_token): +def login_user(oauth_token, *, load_from_db=False): """Log in the user identified by the given token.""" - user = UserClass(oauth_token) + if load_from_db: + user = _load_user(oauth_token) + else: + user = UserClass(oauth_token) flask_login.login_user(user)