|
7 | 7 | from supertokens_python.constants import DASHBOARD_VERSION |
8 | 8 | from supertokens_python.framework import BaseRequest |
9 | 9 | from supertokens_python.framework.fastapi import get_middleware |
10 | | -from supertokens_python.recipe import dashboard, emailpassword, session, usermetadata |
| 10 | +from supertokens_python.recipe import ( |
| 11 | + dashboard, |
| 12 | + emailpassword, |
| 13 | + session, |
| 14 | + usermetadata, |
| 15 | + thirdpartypasswordless, |
| 16 | +) |
| 17 | +import supertokens_python.recipe.thirdpartypasswordless.asyncio as tplasync |
11 | 18 | from supertokens_python.recipe.dashboard import InputOverrideConfig |
12 | 19 | from supertokens_python.recipe.dashboard.interfaces import ( |
13 | 20 | RecipeInterface as DashboardRI, |
14 | 21 | ) |
15 | 22 | from supertokens_python.recipe.dashboard.utils import DashboardConfig |
| 23 | +from supertokens_python.recipe.passwordless import ContactEmailOrPhoneConfig |
16 | 24 | from supertokens_python.recipe.usermetadata.asyncio import update_user_metadata |
17 | 25 | from tests.utils import ( |
18 | 26 | clean_st, |
@@ -203,3 +211,60 @@ async def test_that_first_connection_uri_is_selected_among_multiple_uris( |
203 | 211 | assert f'window.connectionURI = "{first_connection_uri}"' in str(res.text) |
204 | 212 | if st_config: |
205 | 213 | st_config.connection_uri = "http://localhost:3567" |
| 214 | + |
| 215 | + |
| 216 | +async def test_that_get_user_works_with_combination_recipes(app: TestClient): |
| 217 | + def override_dashboard_functions(oi: DashboardRI) -> DashboardRI: |
| 218 | + async def should_allow_access( |
| 219 | + _request: BaseRequest, |
| 220 | + _config: DashboardConfig, |
| 221 | + _user_context: Dict[str, Any], |
| 222 | + ) -> bool: |
| 223 | + return True |
| 224 | + |
| 225 | + oi.should_allow_access = should_allow_access |
| 226 | + return oi |
| 227 | + |
| 228 | + st_args = get_st_init_args( |
| 229 | + [ |
| 230 | + session.init(get_token_transfer_method=lambda _, __, ___: "cookie"), |
| 231 | + thirdpartypasswordless.init( |
| 232 | + contact_config=ContactEmailOrPhoneConfig(), |
| 233 | + flow_type="USER_INPUT_CODE", |
| 234 | + ), |
| 235 | + usermetadata.init(), |
| 236 | + dashboard.init( |
| 237 | + api_key="someKey", |
| 238 | + override=InputOverrideConfig( |
| 239 | + functions=override_dashboard_functions, |
| 240 | + ), |
| 241 | + ), |
| 242 | + ] |
| 243 | + ) |
| 244 | + init(**st_args) |
| 245 | + start_st() |
| 246 | + |
| 247 | + pluser = await tplasync.thirdparty_manually_create_or_update_user( |
| 248 | + "public", "google", "googleid", "[email protected]" |
| 249 | + ) |
| 250 | + |
| 251 | + res = app.get( |
| 252 | + url="/auth/dashboard/api/user", |
| 253 | + params={ |
| 254 | + "userId": "randomid", |
| 255 | + "recipeId": "thirdparty", |
| 256 | + }, |
| 257 | + ) |
| 258 | + res_json = res.json() |
| 259 | + assert res_json["status"] == "NO_USER_FOUND_ERROR" |
| 260 | + |
| 261 | + res = app.get( |
| 262 | + url="/auth/dashboard/api/user", |
| 263 | + params={ |
| 264 | + "userId": pluser.user.user_id, |
| 265 | + "recipeId": "thirdparty", |
| 266 | + }, |
| 267 | + ) |
| 268 | + res_json = res.json() |
| 269 | + assert res_json["status"] == "OK" |
| 270 | + assert res_json["user"]["id"] == pluser.user.user_id |
0 commit comments