Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

Commit 7cf550e

Browse files
committed
fix: changes create magic link return to the full magic link response instead of just the type
1 parent 60c5734 commit 7cf550e

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

passageidentity/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from passageidentity.openapi_client.models.create_magic_link_request import CreateMagicLinkRequest
1515

1616
if TYPE_CHECKING:
17-
from passageidentity.openapi_client.models.magic_link_type import MagicLinkType
17+
from passageidentity.openapi_client.models.magic_link import MagicLink
1818

1919
CreateMagicLinkArgs = CreateMagicLinkRequest
2020

@@ -52,7 +52,7 @@ def validate_jwt(self, token: str) -> str:
5252
msg = f"JWT is not valid: {e}"
5353
raise PassageError(msg) from e
5454

55-
def create_magic_link(self, args: CreateMagicLinkArgs) -> MagicLinkType:
55+
def create_magic_link(self, args: CreateMagicLinkArgs) -> MagicLink:
5656
"""Create a Magic Link for your app."""
5757
magic_link_req = {}
5858
args_dict = args.to_dict() if isinstance(args, CreateMagicLinkRequest) else args
@@ -78,7 +78,7 @@ def create_magic_link(self, args: CreateMagicLinkArgs) -> MagicLinkType:
7878
self.app_id,
7979
magic_link_req, # type: ignore[arg-type]
8080
_headers=self.request_headers,
81-
).magic_link.type
81+
).magic_link
8282
except ApiException as e:
8383
msg = "Could not create a magic link for this app"
8484
raise PassageError.from_response_error(e, msg) from e

passageidentity/passage.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from passageidentity.auth import Auth
1010
from passageidentity.errors import PassageError
1111
from passageidentity.helper import get_auth_token_from_request
12-
from passageidentity.openapi_client.api.magic_links_api import MagicLinksApi
1312
from passageidentity.user import User
1413

1514
from .openapi_client.api import (
@@ -105,36 +104,7 @@ def createMagicLink( # noqa: N802
105104
msg = "No Passage API key provided."
106105
raise PassageError(msg)
107106

108-
magic_link_req = {}
109-
110-
magic_link_req["user_id"] = magicLinkAttributes.get("user_id") or "" # type: ignore # noqa: PGH003
111-
magic_link_req["email"] = magicLinkAttributes.get("email") or "" # type: ignore # noqa: PGH003
112-
magic_link_req["phone"] = magicLinkAttributes.get("phone") or "" # type: ignore # noqa: PGH003
113-
114-
magic_link_req["language"] = magicLinkAttributes.get("language") or "" # type: ignore # noqa: PGH003
115-
magic_link_req["magic_link_path"] = (
116-
magicLinkAttributes.get("magic_link_path") or "" # type: ignore # noqa: PGH003
117-
)
118-
magic_link_req["redirect_url"] = magicLinkAttributes.get("redirect_url") or "" # type: ignore # noqa: PGH003
119-
magic_link_req["send"] = magicLinkAttributes.get("send") or False # type: ignore # noqa: PGH003
120-
magic_link_req["ttl"] = magicLinkAttributes.get("ttl") or 0 # type: ignore # noqa: PGH003
121-
magic_link_req["type"] = magicLinkAttributes.get("type") or "login" # type: ignore # noqa: PGH003
122-
123-
if magicLinkAttributes.get("email"): # type: ignore # noqa: PGH003
124-
magic_link_req["channel"] = magicLinkAttributes.get("channel") or "email" # type: ignore # noqa: PGH003
125-
elif magicLinkAttributes.get("phone"): # type: ignore # noqa: PGH003
126-
magic_link_req["channel"] = magicLinkAttributes.get("channel") or "phone" # type: ignore # noqa: PGH003
127-
128-
try:
129-
client = MagicLinksApi()
130-
return client.create_magic_link(
131-
self.app_id,
132-
magic_link_req, # type: ignore[arg-type]
133-
_headers=self.request_headers,
134-
).magic_link # type: ignore[attr-defined]
135-
except Exception as e:
136-
msg = f"Failed to create magic link: {e}"
137-
raise PassageError(msg) from e
107+
return self.auth.create_magic_link(magicLinkAttributes) # type: ignore[attr-defined]
138108

139109
@typing_extensions.deprecated("Passage.getApp() will be removed without replacement.")
140110
def getApp(self) -> AppInfo | PassageError: # noqa: N802

0 commit comments

Comments
 (0)