Skip to content

Commit 91198a0

Browse files
committed
fixes review comments
1 parent 5e08c6d commit 91198a0

File tree

11 files changed

+52
-74
lines changed

11 files changed

+52
-74
lines changed

supertokens_python/recipe/emailpassword/asyncio/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def get_user_by_email(
7070
if user_context is None:
7171
user_context = {}
7272
return await EmailPasswordRecipe.get_instance().recipe_implementation.get_user_by_email(
73-
tenant_id or DEFAULT_TENANT_ID, email, user_context
73+
tenant_id, email, user_context
7474
)
7575

7676

@@ -80,7 +80,7 @@ async def create_reset_password_token(
8080
if user_context is None:
8181
user_context = {}
8282
return await EmailPasswordRecipe.get_instance().recipe_implementation.create_reset_password_token(
83-
user_id, tenant_id or DEFAULT_TENANT_ID, user_context
83+
user_id, tenant_id, user_context
8484
)
8585

8686

@@ -93,7 +93,7 @@ async def reset_password_using_token(
9393
if user_context is None:
9494
user_context = {}
9595
return await EmailPasswordRecipe.get_instance().recipe_implementation.reset_password_using_token(
96-
new_password, tenant_id or DEFAULT_TENANT_ID, token, user_context
96+
new_password, tenant_id, token, user_context
9797
)
9898

9999

@@ -106,7 +106,7 @@ async def sign_in(
106106
if user_context is None:
107107
user_context = {}
108108
return await EmailPasswordRecipe.get_instance().recipe_implementation.sign_in(
109-
email, password, tenant_id or DEFAULT_TENANT_ID, user_context
109+
email, password, tenant_id, user_context
110110
)
111111

112112

@@ -119,7 +119,7 @@ async def sign_up(
119119
if user_context is None:
120120
user_context = {}
121121
return await EmailPasswordRecipe.get_instance().recipe_implementation.sign_up(
122-
email, password, tenant_id or DEFAULT_TENANT_ID, user_context
122+
email, password, tenant_id, user_context
123123
)
124124

125125

@@ -147,7 +147,7 @@ async def create_reset_password_link(
147147
recipe_instance.get_app_info(),
148148
recipe_instance.get_recipe_id(),
149149
token.token,
150-
tenant_id or DEFAULT_TENANT_ID,
150+
tenant_id,
151151
)
152152
)
153153

supertokens_python/recipe/emailverification/asyncio/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
from supertokens_python.recipe.emailverification.types import EmailTemplateVars
2828
from supertokens_python.recipe.emailverification.recipe import EmailVerificationRecipe
2929

30-
from supertokens_python.recipe.multitenancy.constants import DEFAULT_TENANT_ID
31-
3230
from supertokens_python.recipe.emailverification.utils import get_email_verify_link
3331
from supertokens_python.recipe.emailverification.types import (
3432
VerificationEmailTemplateVars,
@@ -58,7 +56,7 @@ async def create_email_verification_token(
5856
raise Exception("Unknown User ID provided without email")
5957

6058
return await recipe.recipe_implementation.create_email_verification_token(
61-
user_id, email, tenant_id or DEFAULT_TENANT_ID, user_context
59+
user_id, email, tenant_id, user_context
6260
)
6361

6462

@@ -68,7 +66,7 @@ async def verify_email_using_token(
6866
if user_context is None:
6967
user_context = {}
7068
return await EmailVerificationRecipe.get_instance().recipe_implementation.verify_email_using_token(
71-
token, tenant_id or DEFAULT_TENANT_ID, user_context
69+
token, tenant_id, user_context
7270
)
7371

7472

@@ -115,7 +113,7 @@ async def revoke_email_verification_tokens(
115113
raise Exception("Unknown User ID provided without email")
116114

117115
return await EmailVerificationRecipe.get_instance().recipe_implementation.revoke_email_verification_tokens(
118-
user_id, email, tenant_id or DEFAULT_TENANT_ID, user_context
116+
user_id, email, tenant_id, user_context
119117
)
120118

121119

@@ -183,7 +181,7 @@ async def create_email_verification_link(
183181
app_info,
184182
email_verification_token.token,
185183
recipe_instance.get_recipe_id(),
186-
tenant_id or DEFAULT_TENANT_ID,
184+
tenant_id,
187185
)
188186
)
189187

supertokens_python/recipe/multitenancy/recipe_implementation.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from .utils import MultitenancyConfig
4646

4747
from supertokens_python.querier import NormalisedURLPath
48-
from .constants import DEFAULT_TENANT_ID
4948

5049

5150
def parse_tenant_config(tenant: Dict[str, Any]) -> TenantConfigResponse:
@@ -162,9 +161,7 @@ async def get_tenant(
162161
self, tenant_id: Optional[str], user_context: Dict[str, Any]
163162
) -> GetTenantOkResult:
164163
res = await self.querier.send_get_request(
165-
NormalisedURLPath(
166-
f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/tenant"
167-
),
164+
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/tenant"),
168165
)
169166

170167
tenant_config = parse_tenant_config(res)
@@ -209,9 +206,7 @@ async def create_or_update_third_party_config(
209206
user_context: Dict[str, Any],
210207
) -> CreateOrUpdateThirdPartyConfigOkResult:
211208
response = await self.querier.send_put_request(
212-
NormalisedURLPath(
213-
f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/config/thirdparty"
214-
),
209+
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/config/thirdparty"),
215210
{
216211
"config": config.to_json(),
217212
"skipValidation": skip_validation is True,
@@ -230,7 +225,7 @@ async def delete_third_party_config(
230225
) -> DeleteThirdPartyConfigOkResult:
231226
response = await self.querier.send_post_request(
232227
NormalisedURLPath(
233-
f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/config/thirdparty/remove"
228+
f"{tenant_id}/recipe/multitenancy/config/thirdparty/remove"
234229
),
235230
{
236231
"thirdPartyId": third_party_id,
@@ -251,9 +246,7 @@ async def associate_user_to_tenant(
251246
AssociateUserToTenantThirdPartyUserAlreadyExistsError,
252247
]:
253248
response: Dict[str, Any] = await self.querier.send_post_request(
254-
NormalisedURLPath(
255-
f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/tenant/user"
256-
),
249+
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/tenant/user"),
257250
{
258251
"userId": user_id,
259252
},
@@ -284,9 +277,7 @@ async def dissociate_user_from_tenant(
284277
self, tenant_id: str | None, user_id: str, user_context: Dict[str, Any]
285278
) -> DisassociateUserFromTenantOkResult:
286279
response = await self.querier.send_post_request(
287-
NormalisedURLPath(
288-
f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/tenant/user/remove"
289-
),
280+
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/tenant/user/remove"),
290281
{
291282
"userId": user_id,
292283
},

supertokens_python/recipe/session/asyncio/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ async def create_new_session_without_request_response(
107107
final_access_token_payload = {**access_token_payload, "iss": issuer}
108108

109109
for claim in claims_added_by_other_recipes:
110-
update = await claim.build(
111-
user_id, tenant_id or DEFAULT_TENANT_ID, user_context
112-
)
110+
update = await claim.build(user_id, tenant_id, user_context)
113111
final_access_token_payload = {**final_access_token_payload, **update}
114112

115113
return await SessionRecipe.get_instance().recipe_implementation.create_new_session(

supertokens_python/recipe/session/session_functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ async def get_session(
300300
] # if the token didn't pass validation, but we got here, it means it was a v2 token that we didn't have the key cached for.
301301
), # This will throw error if others are none and 'expiryTime' key doesn't exist in the payload
302302
response["session"].get("tenantId")
303-
or (access_token_info or {}).get("tenantId")
304-
or DEFAULT_TENANT_ID,
303+
or (access_token_info or {}).get("tenantId"),
305304
),
306305
GetSessionAPIResponseAccessToken(
307306
response["accessToken"]["token"],

supertokens_python/recipe/thirdparty/asyncio/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
from ..types import User
2020

21-
from supertokens_python.recipe.multitenancy.constants import DEFAULT_TENANT_ID
22-
2321

2422
async def get_user_by_id(
2523
user_id: str, user_context: Union[None, Dict[str, Any]] = None
@@ -38,7 +36,7 @@ async def get_users_by_email(
3836
user_context = {}
3937
return (
4038
await ThirdPartyRecipe.get_instance().recipe_implementation.get_users_by_email(
41-
email, tenant_id or DEFAULT_TENANT_ID, user_context
39+
email, tenant_id, user_context
4240
)
4341
)
4442

supertokens_python/recipe/thirdpartyemailpassword/asyncio/__init__.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def get_user_by_third_party_info(
5757
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.get_user_by_thirdparty_info(
5858
third_party_id,
5959
third_party_user_id,
60-
tenant_id or DEFAULT_TENANT_ID,
60+
tenant_id,
6161
user_context,
6262
)
6363

@@ -75,7 +75,7 @@ async def thirdparty_manually_create_or_update_user(
7575
third_party_id,
7676
third_party_user_id,
7777
email,
78-
tenant_id or DEFAULT_TENANT_ID,
78+
tenant_id,
7979
user_context,
8080
)
8181

@@ -89,7 +89,7 @@ async def thirdparty_get_provider(
8989
if user_context is None:
9090
user_context = {}
9191
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.thirdparty_get_provider(
92-
third_party_id, client_type, tenant_id or DEFAULT_TENANT_ID, user_context
92+
third_party_id, client_type, tenant_id, user_context
9393
)
9494

9595

@@ -99,7 +99,7 @@ async def create_reset_password_token(
9999
if user_context is None:
100100
user_context = {}
101101
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.create_reset_password_token(
102-
user_id, tenant_id or DEFAULT_TENANT_ID, user_context
102+
user_id, tenant_id, user_context
103103
)
104104

105105

@@ -112,7 +112,7 @@ async def reset_password_using_token(
112112
if user_context is None:
113113
user_context = {}
114114
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.reset_password_using_token(
115-
token, new_password, tenant_id or DEFAULT_TENANT_ID, user_context
115+
token, new_password, tenant_id, user_context
116116
)
117117

118118

@@ -125,7 +125,7 @@ async def emailpassword_sign_in(
125125
if user_context is None:
126126
user_context = {}
127127
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.emailpassword_sign_in(
128-
email, password, tenant_id or DEFAULT_TENANT_ID, user_context
128+
email, password, tenant_id, user_context
129129
)
130130

131131

@@ -138,7 +138,7 @@ async def emailpassword_sign_up(
138138
if user_context is None:
139139
user_context = {}
140140
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.emailpassword_sign_up(
141-
email, password, tenant_id or DEFAULT_TENANT_ID, user_context
141+
email, password, tenant_id, user_context
142142
)
143143

144144

@@ -168,7 +168,7 @@ async def get_users_by_email(
168168
if user_context is None:
169169
user_context = {}
170170
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.get_users_by_email(
171-
email, tenant_id or DEFAULT_TENANT_ID, user_context
171+
email, tenant_id, user_context
172172
)
173173

174174

@@ -178,8 +178,6 @@ async def send_email(
178178
):
179179
if user_context is None:
180180
user_context = {}
181-
if input_.tenant_id is None:
182-
input_.tenant_id = DEFAULT_TENANT_ID
183181

184182
return await ThirdPartyEmailPasswordRecipe.get_instance().email_delivery.ingredient_interface_impl.send_email(
185183
input_, user_context
@@ -203,7 +201,7 @@ async def create_reset_password_link(
203201
recipe_instance.get_app_info(),
204202
token.token,
205203
recipe_instance.get_recipe_id(),
206-
tenant_id or DEFAULT_TENANT_ID,
204+
tenant_id,
207205
)
208206
)
209207

0 commit comments

Comments
 (0)