Skip to content

Commit 5557322

Browse files
committed
Merge branch 'fix/session-mt' into feat/dashboard-mt
2 parents 9c49016 + c2c85b7 commit 5557322

File tree

51 files changed

+140
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+140
-175
lines changed

supertokens_python/ingredients/emaildelivery/types.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
class EmailDeliveryInterface(ABC, Generic[_T]):
2626
@abstractmethod
27-
async def send_email(
28-
self, template_vars: _T, tenant_id: str, user_context: Dict[str, Any]
29-
) -> None:
27+
async def send_email(self, template_vars: _T, user_context: Dict[str, Any]) -> None:
3028
pass
3129

3230

supertokens_python/ingredients/smsdelivery/types.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
class SMSDeliveryInterface(ABC, Generic[_T]):
2424
@abstractmethod
25-
async def send_sms(
26-
self, template_vars: _T, tenant_id: str, user_context: Dict[str, Any]
27-
) -> None:
25+
async def send_sms(self, template_vars: _T, user_context: Dict[str, Any]) -> None:
2826
pass
2927

3028

supertokens_python/recipe/dashboard/api/userdetails/user_email_verify_token_post.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def handle_email_verify_token_post(
7070
VerificationEmailTemplateVars(
7171
user=VerificationEmailTemplateVarsUser(user_id, email_response.email),
7272
email_verify_link=email_verify_link,
73-
user_context={},
73+
tenant_id=tenant_id,
7474
)
7575
)
7676

supertokens_python/recipe/emailpassword/api/implementation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ async def generate_password_reset_token_post(
111111
send_email_input = PasswordResetEmailTemplateVars(
112112
user=PasswordResetEmailTemplateVarsUser(user.user_id, user.email),
113113
password_reset_link=password_reset_link,
114+
tenant_id=tenant_id,
114115
)
115116
await api_options.email_delivery.ingredient_interface_impl.send_email(
116-
send_email_input, tenant_id, user_context
117+
send_email_input, user_context
117118
)
118119

119120
return GeneratePasswordResetTokenPostOkResult()

supertokens_python/recipe/emailpassword/asyncio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,10 @@ async def sign_up(
110110

111111
async def send_email(
112112
input_: EmailTemplateVars,
113-
tenant_id: str,
114113
user_context: Union[None, Dict[str, Any]] = None,
115114
):
116115
if user_context is None:
117116
user_context = {}
118117
return await EmailPasswordRecipe.get_instance().email_delivery.ingredient_interface_impl.send_email(
119-
input_, tenant_id, user_context
118+
input_, user_context
120119
)

supertokens_python/recipe/emailpassword/emaildelivery/services/backward_compatibility/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def __init__(
8989
async def send_email(
9090
self,
9191
template_vars: EmailTemplateVars,
92-
tenant_id: str,
9392
user_context: Dict[str, Any],
9493
) -> None:
9594
user = await self.recipe_interface_impl.get_user_by_id(

supertokens_python/recipe/emailpassword/emaildelivery/services/smtp/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def __init__(
4444
async def send_email(
4545
self,
4646
template_vars: EmailTemplateVars,
47-
tenant_id: str,
4847
user_context: Dict[str, Any],
4948
) -> None:
5049
content = await self.service_implementation.get_content(

supertokens_python/recipe/emailpassword/syncio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ def sign_up(
104104

105105
def send_email(
106106
input_: EmailTemplateVars,
107-
tenant_id: str,
108107
user_context: Union[None, Dict[str, Any]] = None,
109108
):
110109
from supertokens_python.recipe.emailpassword.asyncio import send_email
111110

112-
return sync(send_email(input_, tenant_id, user_context))
111+
return sync(send_email(input_, user_context))

supertokens_python/recipe/emailpassword/types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414
from __future__ import annotations
15-
from typing import Awaitable, Callable, List, TypeVar, Union
15+
from typing import Awaitable, Callable, List, TypeVar, Union, Optional
1616

1717
from supertokens_python.ingredients.emaildelivery import EmailDeliveryIngredient
1818
from supertokens_python.ingredients.emaildelivery.types import (
@@ -99,9 +99,11 @@ def __init__(
9999
self,
100100
user: PasswordResetEmailTemplateVarsUser,
101101
password_reset_link: str,
102+
tenant_id: Optional[str],
102103
) -> None:
103104
self.user = user
104105
self.password_reset_link = password_reset_link
106+
self.tenant_id = tenant_id
105107

106108

107109
# Export:

supertokens_python/recipe/emailverification/asyncio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,10 @@ async def unverify_email(
138138

139139
async def send_email(
140140
input_: EmailTemplateVars,
141-
tenant_id: Optional[str] = None,
142141
user_context: Union[None, Dict[str, Any]] = None,
143142
):
144143
if user_context is None:
145144
user_context = {}
146145
return await EmailVerificationRecipe.get_instance().email_delivery.ingredient_interface_impl.send_email(
147-
input_, tenant_id or DEFAULT_TENANT_ID, user_context
146+
input_, user_context
148147
)

supertokens_python/recipe/emailverification/emaildelivery/services/backward_compatibility/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def __init__(
6868
async def send_email(
6969
self,
7070
template_vars: VerificationEmailTemplateVars,
71-
tenant_id: str,
7271
user_context: Dict[str, Any],
7372
) -> None:
7473
try:

supertokens_python/recipe/emailverification/emaildelivery/services/smtp/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def __init__(
4343
async def send_email(
4444
self,
4545
template_vars: VerificationEmailTemplateVars,
46-
tenant_id: str,
4746
user_context: Dict[str, Any],
4847
) -> None:
4948
content = await self.service_implementation.get_content(

supertokens_python/recipe/emailverification/recipe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@ async def generate_email_verify_token_post(
460460
email_verification_email_delivery_input = VerificationEmailTemplateVars(
461461
user=VerificationEmailTemplateVarsUser(user_id, email_info.email),
462462
email_verify_link=email_verify_link,
463-
user_context=user_context,
463+
tenant_id=tenant_id,
464464
)
465465
await api_options.email_delivery.ingredient_interface_impl.send_email(
466-
email_verification_email_delivery_input, tenant_id, user_context
466+
email_verification_email_delivery_input, user_context
467467
)
468468
return GenerateEmailVerifyTokenPostOkResult()
469469

supertokens_python/recipe/emailverification/syncio/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def create_email_verification_token(
3535

3636
def verify_email_using_token(
3737
token: str,
38-
tenant_id: Optional[str],
38+
tenant_id: Optional[str] = None,
3939
user_context: Union[None, Dict[str, Any]] = None,
4040
):
4141
from supertokens_python.recipe.emailverification.asyncio import (
@@ -82,9 +82,8 @@ def unverify_email(
8282

8383
def send_email(
8484
input_: EmailTemplateVars,
85-
tenant_id: Optional[str],
8685
user_context: Union[None, Dict[str, Any]] = None,
8786
):
8887
from supertokens_python.recipe.emailverification.asyncio import send_email
8988

90-
return sync(send_email(input_, tenant_id, user_context))
89+
return sync(send_email(input_, user_context))

supertokens_python/recipe/emailverification/types.py

Lines changed: 3 additions & 3 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 Union, Dict, Any
16+
from typing import Union, Optional
1717

1818
from supertokens_python.ingredients.emaildelivery import EmailDeliveryIngredient
1919
from supertokens_python.ingredients.emaildelivery.types import (
@@ -39,11 +39,11 @@ def __init__(
3939
self,
4040
user: VerificationEmailTemplateVarsUser,
4141
email_verify_link: str,
42-
user_context: Dict[str, Any],
42+
tenant_id: Optional[str],
4343
) -> None:
4444
self.user = user
4545
self.email_verify_link = email_verify_link
46-
self.user_context = user_context
46+
self.tenant_id = tenant_id
4747

4848

4949
# Export:

supertokens_python/recipe/passwordless/api/implementation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ async def create_code_post(
9898
url_with_link_code=magic_link,
9999
code_life_time=response.code_life_time,
100100
pre_auth_session_id=response.pre_auth_session_id,
101+
tenant_id=tenant_id,
101102
)
102103
await api_options.email_delivery.ingredient_interface_impl.send_email(
103-
passwordless_email_delivery_input, tenant_id, user_context
104+
passwordless_email_delivery_input, user_context
104105
)
105106
elif isinstance(
106107
api_options.config.contact_config,
@@ -115,9 +116,10 @@ async def create_code_post(
115116
url_with_link_code=magic_link,
116117
code_life_time=response.code_life_time,
117118
pre_auth_session_id=response.pre_auth_session_id,
119+
tenant_id=tenant_id,
118120
)
119121
await api_options.sms_delivery.ingredient_interface_impl.send_sms(
120-
sms_input, tenant_id, user_context
122+
sms_input, user_context
121123
)
122124

123125
return CreateCodePostOkResult(
@@ -214,10 +216,11 @@ async def resend_code_post(
214216
url_with_link_code=magic_link,
215217
code_life_time=response.code_life_time,
216218
pre_auth_session_id=response.pre_auth_session_id,
219+
tenant_id=tenant_id,
217220
)
218221
)
219222
await api_options.email_delivery.ingredient_interface_impl.send_email(
220-
passwordless_email_delivery_input, tenant_id, user_context
223+
passwordless_email_delivery_input, user_context
221224
)
222225
elif isinstance(
223226
api_options.config.contact_config,
@@ -234,9 +237,10 @@ async def resend_code_post(
234237
url_with_link_code=magic_link,
235238
code_life_time=response.code_life_time,
236239
pre_auth_session_id=response.pre_auth_session_id,
240+
tenant_id=tenant_id,
237241
)
238242
await api_options.sms_delivery.ingredient_interface_impl.send_sms(
239-
sms_input, tenant_id, user_context
243+
sms_input, user_context
240244
)
241245
return ResendCodePostOkResult()
242246
return ResendCodePostRestartFlowError()

supertokens_python/recipe/passwordless/asyncio/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async def get_user_by_email(
133133

134134
async def get_user_by_phone_number(
135135
phone_number: str,
136-
tenant_id: Optional[str],
136+
tenant_id: Optional[str] = None,
137137
user_context: Union[None, Dict[str, Any]] = None,
138138
) -> Union[User, None]:
139139
if user_context is None:
@@ -246,7 +246,7 @@ async def list_codes_by_phone_number(
246246

247247
async def list_codes_by_device_id(
248248
device_id: str,
249-
tenant_id: Optional[str],
249+
tenant_id: Optional[str] = None,
250250
user_context: Union[None, Dict[str, Any]] = None,
251251
) -> Union[DeviceType, None]:
252252
if user_context is None:
@@ -260,7 +260,7 @@ async def list_codes_by_device_id(
260260

261261
async def list_codes_by_pre_auth_session_id(
262262
pre_auth_session_id: str,
263-
tenant_id: Optional[str],
263+
tenant_id: Optional[str] = None,
264264
user_context: Union[None, Dict[str, Any]] = None,
265265
) -> Union[DeviceType, None]:
266266
if user_context is None:
@@ -306,23 +306,27 @@ async def signinup(
306306

307307
async def send_email(
308308
input_: EmailTemplateVars,
309-
tenant_id: Optional[str],
310309
user_context: Union[None, Dict[str, Any]] = None,
311310
):
312311
if user_context is None:
313312
user_context = {}
313+
if input_.tenant_id is None:
314+
input_.tenant_id = DEFAULT_TENANT_ID
315+
314316
return await PasswordlessRecipe.get_instance().email_delivery.ingredient_interface_impl.send_email(
315-
input_, tenant_id or DEFAULT_TENANT_ID, user_context
317+
input_, user_context
316318
)
317319

318320

319321
async def send_sms(
320322
input_: SMSTemplateVars,
321-
tenant_id: Optional[str] = None,
322323
user_context: Union[None, Dict[str, Any]] = None,
323324
):
324325
if user_context is None:
325326
user_context = {}
327+
if input_.tenant_id is None:
328+
input_.tenant_id = DEFAULT_TENANT_ID
329+
326330
return await PasswordlessRecipe.get_instance().sms_delivery.ingredient_interface_impl.send_sms(
327-
input_, tenant_id or DEFAULT_TENANT_ID, user_context
331+
input_, user_context
328332
)

supertokens_python/recipe/passwordless/emaildelivery/services/backward_compatibility/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def __init__(
8888
async def send_email(
8989
self,
9090
template_vars: PasswordlessLoginEmailTemplateVars,
91-
tenant_id: str,
9291
user_context: Dict[str, Any],
9392
) -> None:
9493
await self.create_and_send_custom_email(

supertokens_python/recipe/passwordless/emaildelivery/services/smtp/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def __init__(
4545
async def send_email(
4646
self,
4747
template_vars: PasswordlessLoginEmailTemplateVars,
48-
tenant_id: str,
4948
user_context: Dict[str, Any],
5049
) -> None:
5150
content = await self.service_implementation.get_content(

supertokens_python/recipe/passwordless/smsdelivery/services/backward_compatibility/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def __init__(
110110
async def send_sms(
111111
self,
112112
template_vars: PasswordlessLoginSMSTemplateVars,
113-
tenant_id: str,
114113
user_context: Dict[str, Any],
115114
) -> None:
116115
await self.create_and_send_custom_sms(

supertokens_python/recipe/passwordless/smsdelivery/services/supertokens/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def __init__(self, api_key: str) -> None:
3434
async def send_sms(
3535
self,
3636
template_vars: PasswordlessLoginSMSTemplateVars,
37-
tenant_id: str,
3837
user_context: Dict[str, Any],
3938
) -> None:
4039
supertokens = Supertokens.get_instance()

supertokens_python/recipe/passwordless/smsdelivery/services/twilio/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def __init__(
5656
async def send_sms(
5757
self,
5858
template_vars: PasswordlessLoginSMSTemplateVars,
59-
tenant_id: str,
6059
user_context: Dict[str, Any],
6160
) -> None:
6261
content = await self.service_implementation.get_content(

supertokens_python/recipe/passwordless/syncio/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_user_by_email(
112112

113113
def get_user_by_phone_number(
114114
phone_number: str,
115-
tenant_id: Optional[str],
115+
tenant_id: Optional[str] = None,
116116
user_context: Union[None, Dict[str, Any]] = None,
117117
) -> Union[User, None]:
118118
return sync(
@@ -195,7 +195,7 @@ def list_codes_by_phone_number(
195195

196196
def list_codes_by_device_id(
197197
device_id: str,
198-
tenant_id: Optional[str],
198+
tenant_id: Optional[str] = None,
199199
user_context: Union[None, Dict[str, Any]] = None,
200200
) -> Union[DeviceType, None]:
201201
return sync(
@@ -207,7 +207,7 @@ def list_codes_by_device_id(
207207

208208
def list_codes_by_pre_auth_session_id(
209209
pre_auth_session_id: str,
210-
tenant_id: Optional[str],
210+
tenant_id: Optional[str] = None,
211211
user_context: Union[None, Dict[str, Any]] = None,
212212
) -> Union[DeviceType, None]:
213213
return sync(
@@ -222,7 +222,7 @@ def list_codes_by_pre_auth_session_id(
222222
def create_magic_link(
223223
email: Union[str, None],
224224
phone_number: Union[str, None],
225-
tenant_id: Optional[str],
225+
tenant_id: Optional[str] = None,
226226
user_context: Union[None, Dict[str, Any]] = None,
227227
) -> str:
228228
return sync(
@@ -238,7 +238,7 @@ def create_magic_link(
238238
def signinup(
239239
email: Union[str, None],
240240
phone_number: Union[str, None],
241-
tenant_id: Optional[str],
241+
tenant_id: Optional[str] = None,
242242
user_context: Union[None, Dict[str, Any]] = None,
243243
) -> ConsumeCodeOkResult:
244244
return sync(
@@ -253,15 +253,13 @@ def signinup(
253253

254254
def send_email(
255255
input_: PasswordlessLoginEmailTemplateVars,
256-
tenant_id: Optional[str],
257256
user_context: Union[None, Dict[str, Any]] = None,
258257
) -> None:
259-
return sync(asyncio.send_email(input_, tenant_id, user_context))
258+
return sync(asyncio.send_email(input_, user_context))
260259

261260

262261
def send_sms(
263262
input_: PasswordlessLoginSMSTemplateVars,
264-
tenant_id: Optional[str],
265263
user_context: Union[None, Dict[str, Any]] = None,
266264
) -> None:
267-
return sync(asyncio.send_sms(input_, tenant_id, user_context))
265+
return sync(asyncio.send_sms(input_, user_context))

0 commit comments

Comments
 (0)