Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kinde_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"UserSession",
"permissions",
"claims",
"profiles",
"portals",
"feature_flags"
"StorageFactory",
"FrameworkFactory",
Expand Down
4 changes: 2 additions & 2 deletions kinde_sdk/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from .permissions import permissions
from .claims import claims
from .feature_flags import feature_flags
from .profiles import profiles
from .portals import portals

__all__ = ["OAuth", "TokenManager", "UserSession", "permissions", "claims", "feature_flags", "profiles"]
__all__ = ["OAuth", "TokenManager", "UserSession", "permissions", "claims", "feature_flags", "portals"]
16 changes: 13 additions & 3 deletions kinde_sdk/auth/portals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
import urllib.parse
from urllib.parse import urlparse, URL
import httpx
from enum import Enum
from kinde_sdk.core.framework.framework_factory import FrameworkFactory
from kinde_sdk.auth.user_session import UserSession

class PortalPage(str, Enum):
"""Enum representing the different portal pages available."""
ORGANIZATION_DETAILS = "organization_details"
ORGANIZATION_MEMBERS = "organization_members"
ORGANIZATION_PLAN_DETAILS = "organization_plan_details"
ORGANIZATION_PAYMENT_DETAILS = "organization_payment_details"
ORGANIZATION_PLAN_SELECTION = "organization_plan_selection"
PROFILE = "profile"

class Portals:
def __init__(self):
self._logger = logging.getLogger("kinde_sdk")
Expand Down Expand Up @@ -50,14 +60,14 @@ def _sanitize_url(self, url: str) -> str:
url = 'https://' + url
return url.rstrip('/')

async def generate_portal_url(self, domain: str, return_url: str, sub_nav: str = "profile") -> Dict[str, URL]:
async def generate_portal_url(self, domain: str, return_url: str, sub_nav: PortalPage = PortalPage.PROFILE) -> Dict[str, URL]:
"""
Generates a URL to the user portal.

Args:
domain: The domain of the Kinde instance
return_url: URL to redirect to after completing the portal flow
sub_nav: Sub-navigation section to display (defaults to "profile")
sub_nav: Sub-navigation section to display (defaults to PortalPage.PROFILE)

Returns:
Dict containing the URL to redirect to:
Expand Down Expand Up @@ -85,7 +95,7 @@ async def generate_portal_url(self, domain: str, return_url: str, sub_nav: str =

sanitized_domain = self._sanitize_url(domain)
params = urllib.parse.urlencode({
'sub_nav': sub_nav,
'sub_nav': sub_nav.value,
'return_url': return_url
})

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kinde-python-sdk"
version = "2.0.0-beta.7"
version = "2.0.0-beta.8"
authors = [
{ name = "Kinde Engineering", email = "engineering@kinde.com" },
]
Expand Down