|
9 | 9 | from passageidentity.auth import Auth |
10 | 10 | from passageidentity.errors import PassageError |
11 | 11 | from passageidentity.helper import get_auth_token_from_request |
12 | | -from passageidentity.openapi_client.api.magic_links_api import MagicLinksApi |
13 | 12 | from passageidentity.user import User |
14 | 13 |
|
15 | 14 | from .openapi_client.api import ( |
@@ -105,36 +104,7 @@ def createMagicLink( # noqa: N802 |
105 | 104 | msg = "No Passage API key provided." |
106 | 105 | raise PassageError(msg) |
107 | 106 |
|
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] |
138 | 108 |
|
139 | 109 | @typing_extensions.deprecated("Passage.getApp() will be removed without replacement.") |
140 | 110 | def getApp(self) -> AppInfo | PassageError: # noqa: N802 |
|
0 commit comments