From 06ea37c38102249348fba005ef4a16b4cfcaaa1c Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Fri, 22 Mar 2024 23:37:36 +0300 Subject: Import user_logged_in from the clients module. Importing "user_logged_in" in the checks module just to export adds a layer of indirection and makes the code hard to read. Signed-off-by: Munyoki Kilyungi --- gn2/wqflask/oauth2/checks.py | 6 ++++-- gn2/wqflask/oauth2/collections.py | 2 +- gn2/wqflask/oauth2/toplevel.py | 4 ++-- gn2/wqflask/oauth2/ui.py | 2 +- gn2/wqflask/oauth2/users.py | 5 +++-- 5 files changed, 11 insertions(+), 8 deletions(-) (limited to 'gn2/wqflask/oauth2') diff --git a/gn2/wqflask/oauth2/checks.py b/gn2/wqflask/oauth2/checks.py index 4233e376..9a633b95 100644 --- a/gn2/wqflask/oauth2/checks.py +++ b/gn2/wqflask/oauth2/checks.py @@ -4,11 +4,13 @@ from urllib.parse import urljoin from authlib.integrations.requests_client import OAuth2Session from flask import ( - flash, request, url_for, redirect, current_app, session as flask_session) + flash, request, redirect, session as flask_session) from . import session from .client import ( - authserver_uri, user_logged_in, oauth2_clientid, oauth2_clientsecret) + authserver_uri, oauth2_clientid, oauth2_clientsecret, oauth2_get) +from .session import clear_session_info + def require_oauth2(func): """Decorator for ensuring user is logged in.""" diff --git a/gn2/wqflask/oauth2/collections.py b/gn2/wqflask/oauth2/collections.py index 63bf206e..994867b8 100644 --- a/gn2/wqflask/oauth2/collections.py +++ b/gn2/wqflask/oauth2/collections.py @@ -1,6 +1,6 @@ """Functions for collections.""" from .session import session_info -from .checks import user_logged_in +from .client import user_logged_in from .client import oauth2_get, no_token_get def num_collections() -> int: diff --git a/gn2/wqflask/oauth2/toplevel.py b/gn2/wqflask/oauth2/toplevel.py index 65f60067..dffc0a7c 100644 --- a/gn2/wqflask/oauth2/toplevel.py +++ b/gn2/wqflask/oauth2/toplevel.py @@ -6,8 +6,8 @@ from flask import ( current_app as app) from . import session -from .client import SCOPE, no_token_post -from .checks import require_oauth2, user_logged_in +from .client import SCOPE, no_token_post, user_logged_in +from .checks import require_oauth2 from .request_utils import user_details, process_error toplevel = Blueprint("toplevel", __name__) diff --git a/gn2/wqflask/oauth2/ui.py b/gn2/wqflask/oauth2/ui.py index 04ec3292..cf2e9af7 100644 --- a/gn2/wqflask/oauth2/ui.py +++ b/gn2/wqflask/oauth2/ui.py @@ -2,7 +2,7 @@ from flask import session, render_template from .client import oauth2_get -from .checks import user_logged_in +from .client import user_logged_in from .request_utils import process_error def render_ui(templatepath: str, **kwargs): diff --git a/gn2/wqflask/oauth2/users.py b/gn2/wqflask/oauth2/users.py index 894cce5b..3b2f264a 100644 --- a/gn2/wqflask/oauth2/users.py +++ b/gn2/wqflask/oauth2/users.py @@ -10,8 +10,9 @@ from flask import ( from . import client from . import session from .ui import render_ui -from .checks import require_oauth2, user_logged_in -from .client import oauth2_get, oauth2_post, oauth2_client, authserver_uri +from .checks import require_oauth2 +from .client import (oauth2_get, oauth2_post, oauth2_client, + authserver_uri, user_logged_in) from .request_utils import ( user_details, request_error, process_error, with_flash_error) -- cgit v1.2.3