Skip to content

Commit 5e08c6d

Browse files
committed
fixes review comments
1 parent 84acec2 commit 5e08c6d

File tree

22 files changed

+62
-40
lines changed

22 files changed

+62
-40
lines changed

supertokens_python/recipe/session/asyncio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949

5050

5151
async def create_new_session(
52-
tenant_id: str,
5352
request: Any,
53+
tenant_id: str,
5454
user_id: str,
5555
access_token_payload: Union[Dict[str, Any], None] = None,
5656
session_data_in_database: Union[Dict[str, Any], None] = None,

supertokens_python/recipe/session/syncio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040

4141
def create_new_session(
42-
tenant_id: str,
4342
request: Any,
43+
tenant_id: str,
4444
user_id: str,
4545
access_token_payload: Union[Dict[str, Any], None] = None,
4646
session_data_in_database: Union[Dict[str, Any], None] = None,

supertokens_python/recipe/thirdparty/api/implementation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414
from __future__ import annotations
15-
from supertokens_python.utils import utf_base64decode
1615
from base64 import b64decode
1716
import json
1817

supertokens_python/recipe/thirdpartyemailpassword/asyncio/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
CreateResetPasswordLinkUknownUserIdError,
2727
CreateResetPasswordLinkOkResult,
2828
SendResetPasswordEmailUnknownUserIdError,
29-
SendResetPasswordEmailEmailOkResult
29+
SendResetPasswordEmailEmailOkResult,
3030
)
3131
from supertokens_python.recipe.emailpassword.utils import get_password_reset_link
3232

@@ -61,6 +61,7 @@ async def get_user_by_third_party_info(
6161
user_context,
6262
)
6363

64+
6465
async def thirdparty_manually_create_or_update_user(
6566
tenant_id: str,
6667
third_party_id: str,

supertokens_python/syncio/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,40 @@
2929

3030

3131
def get_users_oldest_first(
32+
tenant_id: str,
3233
limit: Union[int, None] = None,
3334
pagination_token: Union[str, None] = None,
3435
include_recipe_ids: Union[None, List[str]] = None,
3536
query: Union[None, Dict[str, str]] = None,
3637
) -> UsersResponse:
3738
return sync(
3839
Supertokens.get_instance().get_users(
39-
"public", "ASC", limit, pagination_token, include_recipe_ids, query
40+
tenant_id, "ASC", limit, pagination_token, include_recipe_ids, query
4041
)
4142
)
4243

4344

4445
def get_users_newest_first(
46+
tenant_id: str,
4547
limit: Union[int, None] = None,
4648
pagination_token: Union[str, None] = None,
4749
include_recipe_ids: Union[None, List[str]] = None,
4850
query: Union[None, Dict[str, str]] = None,
4951
) -> UsersResponse:
5052
return sync(
5153
Supertokens.get_instance().get_users(
52-
"public", "DESC", limit, pagination_token, include_recipe_ids, query
54+
tenant_id, "DESC", limit, pagination_token, include_recipe_ids, query
5355
)
5456
)
5557

5658

57-
def get_user_count(include_recipe_ids: Union[None, List[str]] = None) -> int:
58-
return sync(Supertokens.get_instance().get_user_count(include_recipe_ids))
59+
def get_user_count(
60+
include_recipe_ids: Union[None, List[str]] = None,
61+
tenant_id: Optional[str] = None,
62+
) -> int:
63+
return sync(
64+
Supertokens.get_instance().get_user_count(include_recipe_ids, tenant_id)
65+
)
5966

6067

6168
def delete_user(user_id: str) -> None:

tests/Django/test_django.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_cookies(response: HttpResponse) -> Dict[str, Any]:
7676

7777

7878
async def create_new_session_view(request: HttpRequest):
79-
await create_new_session("public", request, "user_id")
79+
await create_new_session(request, "public", "user_id")
8080
return JsonResponse({"foo": "bar"})
8181

8282

@@ -456,10 +456,12 @@ async def test_thirdparty_parsing_works(self):
456456

457457
start_st()
458458

459-
state = b64encode(json.dumps({"redirectURI": "http://localhost:3000/redirect" }).encode()).decode()
459+
state = b64encode(
460+
json.dumps({"redirectURI": "http://localhost:3000/redirect"}).encode()
461+
).decode()
460462
code = "testing"
461463

462-
data = { "state": state, "code": code}
464+
data = {"state": state, "code": code}
463465

464466
request = self.factory.post(
465467
"/auth/callback/apple",
@@ -472,8 +474,11 @@ async def test_thirdparty_parsing_works(self):
472474
response = await temp
473475

474476
self.assertEqual(response.status_code, 303)
475-
self.assertEqual(response.content, b'')
476-
self.assertEqual(response.headers['location'], f"http://localhost:3000/redirect?state={state.replace('=', '%3D')}&code={code}")
477+
self.assertEqual(response.content, b"")
478+
self.assertEqual(
479+
response.headers["location"],
480+
f"http://localhost:3000/redirect?state={state.replace('=', '%3D')}&code={code}",
481+
)
477482

478483
@pytest.mark.asyncio
479484
async def test_search_with_multiple_emails(self):

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("public", request, user_id, {}, {})
94+
await create_new_session(request, "public", 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("public", request, "userId", {}, {})
138+
await create_new_session(request, "public", "userId", {}, {})
139139
return ""
140140

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

146146
return TestClient(app)

tests/Flask/test_flask.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def t(): # type: ignore
192192
@app.route("/login") # type: ignore
193193
def login(): # type: ignore
194194
user_id = "userId"
195-
create_new_session("public", request, user_id, {}, {})
195+
create_new_session(request, "public", user_id, {}, {})
196196

197197
return jsonify({"userId": user_id, "session": "ssss"})
198198

@@ -478,15 +478,20 @@ def test_thirdparty_parsing_works(driver_config_app: Any):
478478
start_st()
479479

480480
test_client = driver_config_app.test_client()
481-
state = b64encode(json.dumps({"redirectURI": "http://localhost:3000/redirect" }).encode()).decode()
481+
state = b64encode(
482+
json.dumps({"redirectURI": "http://localhost:3000/redirect"}).encode()
483+
).decode()
482484
code = "testing"
483485

484-
data = { "state": state, "code": code}
486+
data = {"state": state, "code": code}
485487
res = test_client.post("/auth/callback/apple", data=data)
486488

487489
assert res.status_code == 303
488-
assert res.data == b''
489-
assert res.headers["location"] == f"http://localhost:3000/redirect?state={state.replace('=', '%3D')}&code={code}"
490+
assert res.data == b""
491+
assert (
492+
res.headers["location"]
493+
== f"http://localhost:3000/redirect?state={state.replace('=', '%3D')}&code={code}"
494+
)
490495

491496

492497
from flask.wrappers import Response
@@ -747,7 +752,7 @@ def test_api(): # type: ignore
747752
@app.route("/login") # type: ignore
748753
def login(): # type: ignore
749754
user_id = "userId"
750-
s = create_new_session("public", request, user_id, {}, {})
755+
s = create_new_session(request, "public", user_id, {}, {})
751756
return jsonify({"user": s.get_user_id()})
752757

753758
@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("public", request, user_id, {}, {})
53+
await create_new_session(request, "public", 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
@@ -79,7 +79,7 @@ async def driver_config_client():
7979
@app.get("/login")
8080
async def login(request: Request): # type: ignore
8181
user_id = "userId"
82-
await create_new_session("public", request, user_id, {}, {})
82+
await create_new_session(request, "public", user_id, {}, {})
8383
return {"userId": user_id}
8484

8585
@app.post("/refresh")

0 commit comments

Comments
 (0)