Skip to content

Commit

Permalink
Bug: Break circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
fredmanglis committed Mar 6, 2024
1 parent 1e81c74 commit b14fefe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 2 additions & 11 deletions gn2/wqflask/oauth2/checks.py
Expand Up @@ -7,17 +7,8 @@
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."""
Expand Down
13 changes: 12 additions & 1 deletion gn2/wqflask/oauth2/client.py
Expand Up @@ -11,7 +11,6 @@
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 "
Expand All @@ -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(
Expand Down

0 comments on commit b14fefe

Please sign in to comment.