Skip to content

Commit

Permalink
fix: cyclic import
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Dec 30, 2024
1 parent 7e052ca commit c605691
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion supertokens_python/recipe/oauth2provider/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
APIInterface,
)

from .utils import get_session


async def auth_get(
_tenant_id: str,
Expand All @@ -38,7 +40,6 @@ async def auth_get(
RedirectResponse,
ErrorOAuth2Response,
)
from supertokens_python.recipe.session.asyncio import get_session
from supertokens_python.recipe.session.exceptions import TryRefreshTokenError

if api_implementation.disable_auth_get is True:
Expand Down
3 changes: 2 additions & 1 deletion supertokens_python/recipe/oauth2provider/api/end_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from supertokens_python.types import GeneralErrorResponse
from supertokens_python.utils import send_200_response, send_non_200_response

from .utils import get_session

if TYPE_CHECKING:
from ..interfaces import (
APIOptions,
Expand Down Expand Up @@ -82,7 +84,6 @@ async def end_session_common(
user_context: Dict[str, Any],
) -> Optional[BaseResponse]:
from ..interfaces import RedirectResponse, ErrorOAuth2Response
from supertokens_python.recipe.session.asyncio import get_session
from supertokens_python.recipe.session.exceptions import TryRefreshTokenError

if api_implementation is None:
Expand Down
3 changes: 2 additions & 1 deletion supertokens_python/recipe/oauth2provider/api/logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from supertokens_python.framework import BaseResponse
from supertokens_python.utils import send_200_response, send_non_200_response

from .utils import get_session

if TYPE_CHECKING:
from ..interfaces import (
APIOptions,
Expand All @@ -37,7 +39,6 @@ async def logout_post(
FrontendRedirectResponse,
ErrorOAuth2Response,
)
from supertokens_python.recipe.session.asyncio import get_session

if api_implementation.disable_logout_post is True:
return None
Expand Down
7 changes: 4 additions & 3 deletions supertokens_python/recipe/oauth2provider/api/user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from typing import TYPE_CHECKING, Any, Dict, Optional

from supertokens_python.recipe.accountlinking.recipe import AccountLinkingRecipe
from supertokens_python.utils import (
send_200_response,
send_non_200_response_with_message,
Expand All @@ -34,8 +35,6 @@ async def user_info_get(
api_options: APIOptions,
user_context: Dict[str, Any],
):
from supertokens_python.asyncio import get_user

if api_implementation.disable_user_info_get is True:
return None

Expand Down Expand Up @@ -98,7 +97,9 @@ async def user_info_get(

user_id = payload["sub"]

user = await get_user(user_id, user_context)
user = await AccountLinkingRecipe.get_instance().recipe_implementation.get_user(
user_id=user_id, user_context=user_context
)

if user is None:
api_options.response.set_header(
Expand Down
7 changes: 5 additions & 2 deletions supertokens_python/recipe/oauth2provider/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ async def login_get(
FrontendRedirectionURLTypeTryRefresh,
FrontendRedirectionURLTypeLogin,
)
from supertokens_python.recipe.session.asyncio import get_session_information

login_request = await recipe_implementation.get_login_request(
challenge=login_challenge,
Expand All @@ -64,7 +63,11 @@ async def login_get(
return login_request

session_info = (
await get_session_information(session.get_handle()) if session else None
await SessionRecipe.get_instance().recipe_implementation.get_session_information(
session.get_handle(), user_context
)
if session
else None
)
if not session_info:
session = None
Expand Down

0 comments on commit c605691

Please sign in to comment.