Skip to content

Commit 93500de

Browse files
committed
refactor: Revert session related changes
1 parent f8eb3f4 commit 93500de

40 files changed

+98
-179
lines changed

supertokens_python/recipe/emailpassword/api/implementation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ async def sign_in_post(
170170
user = result.user
171171
session = await create_new_session(
172172
api_options.request,
173-
"pass-tenant-id", # TODO: change this to tenant_id
174173
user.user_id,
175174
access_token_payload={},
176175
session_data_in_database={},
@@ -210,7 +209,6 @@ async def sign_up_post(
210209
user = result.user
211210
session = await create_new_session(
212211
api_options.request,
213-
"pass-tenant-id", # TODO: change this to tenant_id
214212
user.user_id,
215213
access_token_payload={},
216214
session_data_in_database={},

supertokens_python/recipe/multitenancy/interfaces.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,5 @@ async def login_methods_get(
336336

337337

338338
TypeGetAllowedDomainsForTenantId = Callable[
339-
[Optional[str], Dict[str, Any]],
340-
Awaitable[Optional[List[str]]]
339+
[Optional[str], Dict[str, Any]], Awaitable[Optional[List[str]]]
341340
]

supertokens_python/recipe/passwordless/api/implementation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ async def consume_code_post(
289289

290290
session = await create_new_session(
291291
api_options.request,
292-
"pass-tenant-id", # TODO: change this to tenant_id
293292
user.user_id,
294293
{},
295294
{},

supertokens_python/recipe/session/asyncio/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
async def create_new_session(
5050
request: Any,
51-
tenant_id: str,
5251
user_id: str,
5352
access_token_payload: Union[Dict[str, Any], None] = None,
5453
session_data_in_database: Union[Dict[str, Any], None] = None,
@@ -67,7 +66,6 @@ async def create_new_session(
6766

6867
return await create_new_session_in_request(
6968
request,
70-
tenant_id,
7169
user_context,
7270
recipe_instance,
7371
access_token_payload,
@@ -79,7 +77,6 @@ async def create_new_session(
7977

8078

8179
async def create_new_session_without_request_response(
82-
tenant_id: str,
8380
user_id: str,
8481
access_token_payload: Union[Dict[str, Any], None] = None,
8582
session_data_in_database: Union[Dict[str, Any], None] = None,
@@ -105,11 +102,10 @@ async def create_new_session_without_request_response(
105102
final_access_token_payload = {**access_token_payload, "iss": issuer}
106103

107104
for claim in claims_added_by_other_recipes:
108-
update = await claim.build(user_id, tenant_id, user_context)
105+
update = await claim.build(user_id, user_context)
109106
final_access_token_payload = {**final_access_token_payload, **update}
110107

111108
return await SessionRecipe.get_instance().recipe_implementation.create_new_session(
112-
tenant_id,
113109
user_id,
114110
final_access_token_payload,
115111
session_data_in_database,

supertokens_python/recipe/session/interfaces.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def __init__(
6969
expiry: int,
7070
custom_claims_in_access_token_payload: Dict[str, Any],
7171
time_created: int,
72-
tenant_id: str,
7372
):
7473
self.session_handle: str = session_handle
7574
self.user_id: str = user_id
@@ -79,7 +78,6 @@ def __init__(
7978
str, Any
8079
] = custom_claims_in_access_token_payload
8180
self.time_created: int = time_created
82-
self.tenant_id: str = tenant_id
8381

8482

8583
class ReqResInfo:
@@ -135,7 +133,6 @@ def __init__(self):
135133
@abstractmethod
136134
async def create_new_session(
137135
self,
138-
tenant_id: str,
139136
user_id: str,
140137
access_token_payload: Optional[Dict[str, Any]],
141138
session_data_in_database: Optional[Dict[str, Any]],
@@ -386,7 +383,6 @@ def __init__(
386383
user_data_in_access_token: Optional[Dict[str, Any]],
387384
req_res_info: Optional[ReqResInfo],
388385
access_token_updated: bool,
389-
tenant_id: str,
390386
):
391387
self.recipe_implementation = recipe_implementation
392388
self.config = config
@@ -399,7 +395,6 @@ def __init__(
399395
self.user_data_in_access_token = user_data_in_access_token
400396
self.req_res_info: Optional[ReqResInfo] = req_res_info
401397
self.access_token_updated = access_token_updated
402-
self.tenant_id = tenant_id
403398

404399
self.response_mutators: List[ResponseMutator] = []
405400

@@ -441,10 +436,6 @@ async def merge_into_access_token_payload(
441436
def get_user_id(self, user_context: Optional[Dict[str, Any]] = None) -> str:
442437
pass
443438

444-
@abstractmethod
445-
def get_tenant_id(self, user_context: Optional[Dict[str, Any]] = None) -> str:
446-
pass
447-
448439
@abstractmethod
449440
def get_access_token_payload(
450441
self, user_context: Optional[Dict[str, Any]] = None
@@ -637,14 +628,13 @@ def get_value_from_payload(
637628
"""Gets the value of the claim stored in the payload"""
638629

639630
async def build(
640-
self,
641-
user_id: str,
642-
tenant_id: str,
643-
user_context: Optional[Dict[str, Any]] = None,
631+
self, user_id: str, user_context: Optional[Dict[str, Any]] = None
644632
) -> JSONObject:
645633
if user_context is None:
646634
user_context = {}
647-
value = await resolve(self.fetch_value(user_id, tenant_id, user_context))
635+
636+
# TODO: change this to tenant_id
637+
value = await resolve(self.fetch_value(user_id, "pass-tenant-id", user_context))
648638

649639
if value is None:
650640
return {}

supertokens_python/recipe/session/recipe_implementation.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def __init__(self, querier: Querier, config: SessionConfig, app_info: AppInfo):
6060

6161
async def create_new_session(
6262
self,
63-
tenant_id: str,
6463
user_id: str,
6564
access_token_payload: Optional[Dict[str, Any]],
6665
session_data_in_database: Optional[Dict[str, Any]],
@@ -96,7 +95,6 @@ async def create_new_session(
9695
payload,
9796
None,
9897
True,
99-
tenant_id,
10098
)
10199

102100
return new_session
@@ -264,7 +262,6 @@ async def get_session(
264262
payload,
265263
None,
266264
access_token_updated,
267-
response.session.tenantId,
268265
)
269266

270267
return session
@@ -315,7 +312,6 @@ async def refresh_session(
315312
user_data_in_access_token=payload,
316313
req_res_info=None,
317314
access_token_updated=True,
318-
tenant_id=payload["tId"],
319315
)
320316

321317
return session
@@ -388,7 +384,7 @@ async def fetch_and_set_claim(
388384
return False
389385

390386
access_token_payload_update = await claim.build(
391-
session_info.user_id, session_info.tenant_id, user_context
387+
session_info.user_id, user_context
392388
)
393389
return await self.merge_into_access_token_payload(
394390
session_handle, access_token_payload_update, user_context

supertokens_python/recipe/session/session_class.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from typing import Any, Dict, List, TypeVar, Union, Optional
14+
from typing import Any, Dict, List, TypeVar, Union
1515

1616
from supertokens_python.recipe.session.exceptions import (
1717
raise_invalid_claims_exception,
@@ -133,9 +133,6 @@ async def update_session_data_in_database(
133133
def get_user_id(self, user_context: Union[Dict[str, Any], None] = None) -> str:
134134
return self.user_id
135135

136-
def get_tenant_id(self, user_context: Optional[Dict[str, Any]] = None) -> str:
137-
return self.tenant_id
138-
139136
def get_access_token_payload(
140137
self, user_context: Union[Dict[str, Any], None] = None
141138
) -> Dict[str, Any]:
@@ -223,9 +220,7 @@ async def fetch_and_set_claim(
223220
if user_context is None:
224221
user_context = {}
225222

226-
update = await claim.build(
227-
self.get_user_id(), self.get_tenant_id(), user_context
228-
)
223+
update = await claim.build(self.get_user_id(), user_context)
229224
return await self.merge_into_access_token_payload(update, user_context)
230225

231226
async def set_claim_value(

supertokens_python/recipe/session/session_functions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ def __init__(
6666
userId: str,
6767
userDataInJWT: Dict[str, Any],
6868
expiryTime: int,
69-
tenantId: str,
7069
) -> None:
7170
self.handle = handle
7271
self.userId = userId
7372
self.userDataInJWT = userDataInJWT
7473
self.expiryTime = expiryTime
75-
self.tenantId = tenantId
7674

7775

7876
class GetSessionAPIResponseAccessToken:
@@ -256,7 +254,6 @@ async def get_session(
256254
access_token_info["userId"],
257255
access_token_info["userData"],
258256
access_token_info["expiryTime"],
259-
access_token_info["tenantId"],
260257
)
261258
)
262259

@@ -295,7 +292,6 @@ async def get_session(
295292
"expiryTime"
296293
] # 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.
297294
), # This will throw error if others are none and 'expiryTime' key doesn't exist in the payload
298-
response["session"]["tenantId"],
299295
),
300296
GetSessionAPIResponseAccessToken(
301297
response["accessToken"]["token"],
@@ -459,6 +455,5 @@ async def get_session_information(
459455
response["expiry"],
460456
response["userDataInJWT"],
461457
response["timeCreated"],
462-
response["tenantId"],
463458
)
464459
return None

supertokens_python/recipe/session/session_request_functions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ async def get_session_from_request(
210210

211211
async def create_new_session_in_request(
212212
request: Any,
213-
tenant_id: str,
214213
user_context: Dict[str, Any],
215214
recipe_instance: SessionRecipe,
216215
access_token_payload: Dict[str, Any],
@@ -239,7 +238,7 @@ async def create_new_session_in_request(
239238
final_access_token_payload = {**access_token_payload, "iss": issuer}
240239

241240
for claim in claims_added_by_other_recipes:
242-
update = await claim.build(user_id, tenant_id, user_context)
241+
update = await claim.build(user_id, user_context)
243242
final_access_token_payload = {**final_access_token_payload, **update}
244243

245244
log_debug_message("createNewSession: Access token payload built")
@@ -276,7 +275,6 @@ async def create_new_session_in_request(
276275

277276
disable_anti_csrf = output_transfer_method == "header"
278277
session = await recipe_instance.recipe_implementation.create_new_session(
279-
tenant_id,
280278
user_id,
281279
final_access_token_payload,
282280
session_data_in_database,

supertokens_python/recipe/session/syncio/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
def create_new_session(
4242
request: Any,
43-
tenant_id: str,
4443
user_id: str,
4544
access_token_payload: Union[Dict[str, Any], None] = None,
4645
session_data_in_database: Union[Dict[str, Any], None] = None,
@@ -53,7 +52,6 @@ def create_new_session(
5352
return sync(
5453
async_create_new_session(
5554
request,
56-
tenant_id,
5755
user_id,
5856
access_token_payload,
5957
session_data_in_database,
@@ -63,7 +61,6 @@ def create_new_session(
6361

6462

6563
def create_new_session_without_request_response(
66-
tenant_id: str,
6764
user_id: str,
6865
access_token_payload: Union[Dict[str, Any], None] = None,
6966
session_data_in_database: Union[Dict[str, Any], None] = None,
@@ -76,7 +73,6 @@ def create_new_session_without_request_response(
7673

7774
return sync(
7875
async_create_new_session_without_request_response(
79-
tenant_id,
8076
user_id,
8177
access_token_payload,
8278
session_data_in_database,

supertokens_python/recipe/thirdparty/api/implementation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ async def sign_in_up_post(
126126
user = signinup_response.user
127127
session = await create_new_session(
128128
api_options.request,
129-
"pass-tenant-id", # TODO: change this to tenant_id
130129
user.user_id,
131130
user_context=user_context,
132131
)

tests/Django/test_django.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_cookies(response: HttpResponse) -> Dict[str, Any]:
7575

7676

7777
async def create_new_session_view(request: HttpRequest):
78-
await create_new_session(request, "public", "user_id")
78+
await create_new_session(request, "user_id")
7979
return JsonResponse({"foo": "bar"})
8080

8181

tests/Fastapi/test_fastapi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def driver_config_client():
9191
@app.get("/login")
9292
async def login(request: Request): # type: ignore
9393
user_id = "userId"
94-
await create_new_session(request, "public", user_id, {}, {})
94+
await create_new_session(request, user_id, {}, {})
9595
return {"userId": user_id}
9696

9797
@app.post("/refresh")
@@ -135,12 +135,12 @@ async def custom_logout(request: Request): # type: ignore
135135

136136
@app.post("/create")
137137
async def _create(request: Request): # type: ignore
138-
await create_new_session(request, "public", "userId", {}, {})
138+
await create_new_session(request, "userId", {}, {})
139139
return ""
140140

141141
@app.post("/create-throw")
142142
async def _create_throw(request: Request): # type: ignore
143-
await create_new_session(request, "public", "userId", {}, {})
143+
await create_new_session(request, "userId", {}, {})
144144
raise UnauthorisedError("unauthorised")
145145

146146
return TestClient(app)

tests/Flask/test_flask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def t(): # type: ignore
188188
@app.route("/login") # type: ignore
189189
def login(): # type: ignore
190190
user_id = "userId"
191-
create_new_session(request, "public", user_id, {}, {})
191+
create_new_session(request, user_id, {}, {})
192192

193193
return jsonify({"userId": user_id, "session": "ssss"})
194194

@@ -745,7 +745,7 @@ def test_api(): # type: ignore
745745
@app.route("/login") # type: ignore
746746
def login(): # type: ignore
747747
user_id = "userId"
748-
s = create_new_session(request, "public", user_id, {}, {})
748+
s = create_new_session(request, user_id, {}, {})
749749
return jsonify({"user": s.get_user_id()})
750750

751751
@app.route("/ping") # type: ignore

tests/emailpassword/test_emailexists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def driver_config_client():
5050
@app.get("/login")
5151
async def login(request: Request): # type: ignore
5252
user_id = "userId"
53-
await create_new_session(request, "public", user_id, {}, {})
53+
await create_new_session(request, user_id, {}, {})
5454
return {"userId": user_id}
5555

5656
@app.post("/refresh")

tests/emailpassword/test_emailverify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async def driver_config_client():
7777
@app.get("/login")
7878
async def login(request: Request): # type: ignore
7979
user_id = "userId"
80-
await create_new_session(request, "public", user_id, {}, {})
80+
await create_new_session(request, user_id, {}, {})
8181
return {"userId": user_id}
8282

8383
@app.post("/refresh")

tests/emailpassword/test_passwordreset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def driver_config_client():
5151
@app.get("/login")
5252
async def login(request: Request): # type: ignore
5353
user_id = "userId"
54-
await create_new_session(request, "public", user_id, {}, {})
54+
await create_new_session(request, user_id, {}, {})
5555
return {"userId": user_id}
5656

5757
@app.post("/refresh")

tests/emailpassword/test_signin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def driver_config_client():
6060
@app.get("/login")
6161
async def login(request: Request): # type: ignore
6262
user_id = "userId"
63-
await create_new_session(request, "public", user_id, {}, {})
63+
await create_new_session(request, user_id, {}, {})
6464
return {"userId": user_id}
6565

6666
@app.post("/refresh")

0 commit comments

Comments
 (0)