diff options
author | Frederick Muriuki Muriithi | 2024-03-06 06:14:09 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-03-06 06:14:43 +0300 |
commit | b14fefe25f1536e2376efa6b0dba9dce33609725 (patch) | |
tree | 0e10d4b6917a69bb01538794b052380187288367 /gn2/wqflask/oauth2/client.py | |
parent | 1e81c74ee8752ad2913b4e610ba7575638755385 (diff) | |
download | genenetwork2-b14fefe25f1536e2376efa6b0dba9dce33609725.tar.gz |
Bug: Break circular import
Diffstat (limited to 'gn2/wqflask/oauth2/client.py')
-rw-r--r-- | gn2/wqflask/oauth2/client.py | 13 |
1 files changed, 12 insertions, 1 deletions
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( |