From b14fefe25f1536e2376efa6b0dba9dce33609725 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 6 Mar 2024 06:14:09 +0300 Subject: Bug: Break circular import --- gn2/wqflask/oauth2/client.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gn2/wqflask/oauth2/client.py') diff --git a/gn2/wqflask/oauth2/client.py b/gn2/wqflask/oauth2/client.py index b538491b..4e2c67f2 100644 --- a/gn2/wqflask/oauth2/client.py +++ b/gn2/wqflask/oauth2/client.py @@ -11,7 +11,6 @@ from pymonad.either import Left, Right, Either from authlib.integrations.requests_client import OAuth2Session from gn2.wqflask.oauth2 import session -from gn2.wqflask.oauth2.checks import user_logged_in from gn2.wqflask.external_errors import ExternalRequestError SCOPE = ("profile group role resource register-client user masquerade " @@ -29,6 +28,18 @@ def oauth2_clientsecret(): """Return the client secret.""" return app.config["OAUTH2_CLIENT_SECRET"] + +def user_logged_in(): + """Check whether the user has logged in.""" + suser = session.session_info()["user"] + if suser["logged_in"]: + if session.expired(): + session.clear_session_info() + return False + return suser["token"].is_right() + return False + + def oauth2_client(): def __client__(token) -> OAuth2Session: return OAuth2Session( -- cgit v1.2.3