Skip to content

Commit 3df9f16

Browse files
committed
Remove get_link_domain_and_path function and ev logic from other recipes
1 parent 27282d4 commit 3df9f16

File tree

8 files changed

+4
-178
lines changed

8 files changed

+4
-178
lines changed

supertokens_python/recipe/emailpassword/utils.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
BackwardCompatibilityService,
2525
)
2626

27-
from ..emailverification.types import User as EmailVerificationUser
2827
from .interfaces import APIInterface, RecipeInterface
2928
from .types import InputFormField, NormalisedFormField, EmailTemplateVars, User
3029

3130
if TYPE_CHECKING:
32-
from .recipe import EmailPasswordRecipe
3331
from supertokens_python.supertokens import AppInfo
3432

3533
from typing import Dict
@@ -233,40 +231,6 @@ def validate_and_normalise_reset_password_using_token_config(
233231
)
234232

235233

236-
def email_verification_create_and_send_custom_email(
237-
recipe: EmailPasswordRecipe,
238-
create_and_send_custom_email: Callable[
239-
[User, str, Dict[str, Any]], Awaitable[None]
240-
],
241-
) -> Callable[[EmailVerificationUser, str, Dict[str, Any]], Awaitable[None]]:
242-
async def func(
243-
user: EmailVerificationUser, link: str, user_context: Dict[str, Any]
244-
):
245-
user_info = await recipe.recipe_implementation.get_user_by_id(
246-
user.user_id, user_context
247-
)
248-
if user_info is None:
249-
raise Exception("Unknown User ID provided")
250-
return await create_and_send_custom_email(user_info, link, user_context)
251-
252-
return func
253-
254-
255-
def email_verification_get_email_verification_url(
256-
recipe: EmailPasswordRecipe,
257-
get_email_verification_url: Callable[[User, Any], Awaitable[str]],
258-
) -> Callable[[EmailVerificationUser, Any], Awaitable[str]]:
259-
async def func(user: EmailVerificationUser, user_context: Dict[str, Any]):
260-
user_info = await recipe.recipe_implementation.get_user_by_id(
261-
user.user_id, user_context
262-
)
263-
if user_info is None:
264-
raise Exception("Unknown User ID provided")
265-
return await get_email_verification_url(user_info, user_context)
266-
267-
return func
268-
269-
270234
class InputOverrideConfig:
271235
def __init__(
272236
self,
@@ -346,7 +310,6 @@ def get_email_delivery_config(
346310
app_info=app_info,
347311
recipe_interface_impl=ep_recipe,
348312
reset_password_using_token_feature=reset_password_using_token_feature,
349-
# email_verification_feature=email_verification_feature,
350313
)
351314
if email_delivery is not None and email_delivery.override is not None:
352315
override = email_delivery.override

supertokens_python/recipe/passwordless/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def init(
5555
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
5656
],
5757
override: Union[InputOverrideConfig, None] = None,
58-
get_link_domain_and_path: Union[
59-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
60-
] = None,
6158
get_custom_user_input_code: Union[
6259
Callable[[Dict[str, Any]], Awaitable[str]], None
6360
] = None,
@@ -68,7 +65,6 @@ def init(
6865
contact_config,
6966
flow_type,
7067
override,
71-
get_link_domain_and_path,
7268
get_custom_user_input_code,
7369
email_delivery,
7470
sms_delivery,

supertokens_python/recipe/passwordless/recipe.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
from .utils import (
5353
ContactConfig,
5454
OverrideConfig,
55-
PhoneOrEmailInput,
5655
validate_and_normalise_user_input,
5756
)
5857
from ..emailverification import EmailVerificationRecipe
@@ -90,9 +89,6 @@ def __init__(
9089
],
9190
ingredients: PasswordlessIngredients,
9291
override: Union[OverrideConfig, None] = None,
93-
get_link_domain_and_path: Union[
94-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
95-
] = None,
9692
get_custom_user_input_code: Union[
9793
Callable[[Dict[str, Any]], Awaitable[str]], None
9894
] = None,
@@ -109,7 +105,6 @@ def __init__(
109105
contact_config,
110106
flow_type,
111107
override,
112-
get_link_domain_and_path,
113108
get_custom_user_input_code,
114109
email_delivery,
115110
sms_delivery,
@@ -235,9 +230,6 @@ def init(
235230
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
236231
],
237232
override: Union[OverrideConfig, None] = None,
238-
get_link_domain_and_path: Union[
239-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
240-
] = None,
241233
get_custom_user_input_code: Union[
242234
Callable[[Dict[str, Any]], Awaitable[str]], None
243235
] = None,
@@ -258,7 +250,6 @@ def func(app_info: AppInfo):
258250
flow_type,
259251
ingredients,
260252
override,
261-
get_link_domain_and_path,
262253
get_custom_user_input_code,
263254
email_delivery,
264255
sms_delivery,

supertokens_python/recipe/passwordless/utils.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,6 @@ async def default_validate_phone_number(value: str):
6262
return "Phone number is invalid"
6363

6464

65-
def default_get_link_domain_and_path(app_info: AppInfo):
66-
async def get_link_domain_and_path(_: PhoneOrEmailInput, __: Dict[str, Any]) -> str:
67-
return (
68-
app_info.website_domain.get_as_string_dangerous()
69-
+ app_info.website_base_path.get_as_string_dangerous()
70-
+ "/verify"
71-
)
72-
73-
return get_link_domain_and_path
74-
75-
7665
async def default_validate_email(value: str):
7766
pattern = r"^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$"
7867
if fullmatch(pattern, value) is None:
@@ -211,9 +200,6 @@ def __init__(
211200
flow_type: Literal[
212201
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
213202
],
214-
get_link_domain_and_path: Callable[
215-
[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]
216-
],
217203
get_email_delivery_config: Callable[
218204
[], EmailDeliveryConfigWithService[PasswordlessLoginEmailTemplateVars]
219205
],
@@ -230,7 +216,6 @@ def __init__(
230216
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
231217
] = flow_type
232218
self.get_custom_user_input_code = get_custom_user_input_code
233-
self.get_link_domain_and_path = get_link_domain_and_path
234219
self.get_email_delivery_config = get_email_delivery_config
235220
self.get_sms_delivery_config = get_sms_delivery_config
236221

@@ -242,9 +227,6 @@ def validate_and_normalise_user_input(
242227
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
243228
],
244229
override: Union[OverrideConfig, None] = None,
245-
get_link_domain_and_path: Union[
246-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
247-
] = None,
248230
get_custom_user_input_code: Union[
249231
Callable[[Dict[str, Any]], Awaitable[str]], None
250232
] = None,
@@ -259,9 +241,6 @@ def validate_and_normalise_user_input(
259241
if override is None:
260242
override = OverrideConfig()
261243

262-
if get_link_domain_and_path is None:
263-
get_link_domain_and_path = default_get_link_domain_and_path(app_info)
264-
265244
def get_email_delivery_config() -> EmailDeliveryConfigWithService[
266245
PasswordlessLoginEmailTemplateVars
267246
]:
@@ -330,7 +309,6 @@ def get_sms_delivery_config() -> SMSDeliveryConfigWithService[
330309
contact_config=contact_config,
331310
override=OverrideConfig(functions=override.functions, apis=override.apis),
332311
flow_type=flow_type,
333-
get_link_domain_and_path=get_link_domain_and_path,
334312
get_email_delivery_config=get_email_delivery_config,
335313
get_sms_delivery_config=get_sms_delivery_config,
336314
get_custom_user_input_code=get_custom_user_input_code,

supertokens_python/recipe/thirdpartyemailpassword/utils.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# under the License.
1414
from __future__ import annotations
1515

16-
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Union
16+
from typing import TYPE_CHECKING, Callable, List, Union
1717

1818
from supertokens_python.ingredients.emaildelivery.types import (
1919
EmailDeliveryConfig,
@@ -28,49 +28,14 @@
2828
InputResetPasswordUsingTokenFeature,
2929
InputSignUpFeature,
3030
)
31-
from ..emailverification.types import User as EmailVerificationUser
3231
from .emaildelivery.services.backward_compatibility import BackwardCompatibilityService
3332
from .interfaces import APIInterface, RecipeInterface
34-
from .types import EmailTemplateVars, User
33+
from .types import EmailTemplateVars
3534

3635
if TYPE_CHECKING:
3736
from .recipe import ThirdPartyEmailPasswordRecipe
3837

3938

40-
def email_verification_create_and_send_custom_email(
41-
recipe: ThirdPartyEmailPasswordRecipe,
42-
create_and_send_custom_email: Callable[
43-
[User, str, Dict[str, Any]], Awaitable[None]
44-
],
45-
) -> Callable[[EmailVerificationUser, str, Dict[str, Any]], Awaitable[None]]:
46-
async def func(
47-
user: EmailVerificationUser, link: str, user_context: Dict[str, Any]
48-
):
49-
user_info = await recipe.recipe_implementation.get_user_by_id(
50-
user.user_id, user_context
51-
)
52-
if user_info is None:
53-
raise Exception("Unknown User ID provided")
54-
return await create_and_send_custom_email(user_info, link, user_context)
55-
56-
return func
57-
58-
59-
def email_verification_get_email_verification_url(
60-
recipe: ThirdPartyEmailPasswordRecipe,
61-
get_email_verification_url: Callable[[User, Any], Awaitable[str]],
62-
) -> Callable[[EmailVerificationUser, Any], Awaitable[str]]:
63-
async def func(user: EmailVerificationUser, user_context: Dict[str, Any]):
64-
user_info = await recipe.recipe_implementation.get_user_by_id(
65-
user.user_id, user_context
66-
)
67-
if user_info is None:
68-
raise Exception("Unknown User ID provided")
69-
return await get_email_verification_url(user_info, user_context)
70-
71-
return func
72-
73-
7439
class InputOverrideConfig:
7540
def __init__(
7641
self,

supertokens_python/recipe/thirdpartypasswordless/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ def init(
5656
flow_type: Literal[
5757
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
5858
],
59-
get_link_domain_and_path: Union[
60-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
61-
] = None,
6259
get_custom_user_input_code: Union[
6360
Callable[[Dict[str, Any]], Awaitable[str]], None
6461
] = None,
@@ -70,7 +67,6 @@ def init(
7067
return ThirdPartyPasswordlessRecipe.init(
7168
contact_config,
7269
flow_type,
73-
get_link_domain_and_path,
7470
get_custom_user_input_code,
7571
email_delivery,
7672
sms_delivery,

supertokens_python/recipe/thirdpartypasswordless/recipe.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
)
2929
from supertokens_python.recipe_module import APIHandled, RecipeModule
3030

31-
from ..passwordless.utils import ContactConfig, PhoneOrEmailInput
31+
from ..passwordless.utils import ContactConfig
3232
from .api.implementation import APIImplementation
3333
from .api.passwordless_api_impementation import (
3434
get_interface_impl as get_passwordless_interface_impl,
@@ -88,9 +88,6 @@ def __init__(
8888
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
8989
],
9090
ingredients: ThirdPartyPasswordlessIngredients,
91-
get_link_domain_and_path: Union[
92-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
93-
] = None,
9491
get_custom_user_input_code: Union[
9592
Callable[[Dict[str, Any]], Awaitable[str]], None
9693
] = None,
@@ -107,7 +104,6 @@ def __init__(
107104
contact_config=contact_config,
108105
flow_type=flow_type,
109106
get_custom_user_input_code=get_custom_user_input_code,
110-
get_link_domain_and_path=get_link_domain_and_path,
111107
override=override,
112108
providers=providers,
113109
email_delivery=email_delivery,
@@ -175,7 +171,6 @@ def apis_override_passwordless(
175171
PlessOverrideConfig(
176172
func_override_passwordless, apis_override_passwordless
177173
),
178-
self.config.get_link_domain_and_path,
179174
self.config.get_custom_user_input_code,
180175
)
181176

@@ -276,9 +271,6 @@ def init(
276271
flow_type: Literal[
277272
"USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"
278273
],
279-
get_link_domain_and_path: Union[
280-
Callable[[PhoneOrEmailInput, Dict[str, Any]], Awaitable[str]], None
281-
] = None,
282274
get_custom_user_input_code: Union[
283275
Callable[[Dict[str, Any]], Awaitable[str]], None
284276
] = None,
@@ -296,7 +288,6 @@ def func(app_info: AppInfo):
296288
contact_config,
297289
flow_type,
298290
ingredients,
299-
get_link_domain_and_path,
300291
get_custom_user_input_code,
301292
override,
302293
providers,

0 commit comments

Comments
 (0)