aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/oauth2
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-03-06 06:14:09 +0300
committerFrederick Muriuki Muriithi2024-03-06 06:14:43 +0300
commitb14fefe25f1536e2376efa6b0dba9dce33609725 (patch)
tree0e10d4b6917a69bb01538794b052380187288367 /gn2/wqflask/oauth2
parent1e81c74ee8752ad2913b4e610ba7575638755385 (diff)
downloadgenenetwork2-b14fefe25f1536e2376efa6b0dba9dce33609725.tar.gz
Bug: Break circular import
Diffstat (limited to 'gn2/wqflask/oauth2')
-rw-r--r--gn2/wqflask/oauth2/checks.py13
-rw-r--r--gn2/wqflask/oauth2/client.py13
2 files changed, 14 insertions, 12 deletions
diff --git a/gn2/wqflask/oauth2/checks.py b/gn2/wqflask/oauth2/checks.py
index 1d355ed8..070e956d 100644
--- a/gn2/wqflask/oauth2/checks.py
+++ b/gn2/wqflask/oauth2/checks.py
@@ -7,17 +7,8 @@ from flask import (
flash, request, url_for, redirect, current_app, session as flask_session)
from . import session
-from .client import authserver_uri, oauth2_clientid, oauth2_clientsecret
-
-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
+from .client import (
+ authserver_uri, user_logged_in, oauth2_clientid, oauth2_clientsecret)
def require_oauth2(func):
"""Decorator for ensuring user is logged in."""
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(