-
Notifications
You must be signed in to change notification settings - Fork 42
fix: Fixes issue with thirdparty passwordless user in dashboard #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,20 @@ | |
from supertokens_python.constants import DASHBOARD_VERSION | ||
from supertokens_python.framework import BaseRequest | ||
from supertokens_python.framework.fastapi import get_middleware | ||
from supertokens_python.recipe import dashboard, emailpassword, session, usermetadata | ||
from supertokens_python.recipe import ( | ||
dashboard, | ||
emailpassword, | ||
session, | ||
usermetadata, | ||
thirdpartypasswordless, | ||
) | ||
import supertokens_python.recipe.thirdpartypasswordless.asyncio as tplasync | ||
from supertokens_python.recipe.dashboard import InputOverrideConfig | ||
from supertokens_python.recipe.dashboard.interfaces import ( | ||
RecipeInterface as DashboardRI, | ||
) | ||
from supertokens_python.recipe.dashboard.utils import DashboardConfig | ||
from supertokens_python.recipe.passwordless import ContactEmailOrPhoneConfig | ||
from supertokens_python.recipe.usermetadata.asyncio import update_user_metadata | ||
from tests.utils import ( | ||
clean_st, | ||
|
@@ -203,3 +211,60 @@ async def test_that_first_connection_uri_is_selected_among_multiple_uris( | |
assert f'window.connectionURI = "{first_connection_uri}"' in str(res.text) | ||
if st_config: | ||
st_config.connection_uri = "http://localhost:3567" | ||
|
||
|
||
async def test_that_get_user_works_with_combination_recipes(app: TestClient): | ||
def override_dashboard_functions(oi: DashboardRI) -> DashboardRI: | ||
async def should_allow_access( | ||
_request: BaseRequest, | ||
_config: DashboardConfig, | ||
_user_context: Dict[str, Any], | ||
) -> bool: | ||
return True | ||
|
||
oi.should_allow_access = should_allow_access | ||
return oi | ||
|
||
st_args = get_st_init_args( | ||
[ | ||
session.init(get_token_transfer_method=lambda _, __, ___: "cookie"), | ||
thirdpartypasswordless.init( | ||
contact_config=ContactEmailOrPhoneConfig(), | ||
flow_type="USER_INPUT_CODE", | ||
), | ||
usermetadata.init(), | ||
dashboard.init( | ||
api_key="someKey", | ||
override=InputOverrideConfig( | ||
functions=override_dashboard_functions, | ||
), | ||
), | ||
] | ||
) | ||
init(**st_args) | ||
start_st() | ||
|
||
pluser = await tplasync.thirdparty_manually_create_or_update_user( | ||
"public", "google", "googleid", "[email protected]" | ||
) | ||
|
||
res = app.get( | ||
url="/auth/dashboard/api/user", | ||
params={ | ||
"userId": "randomid", | ||
"recipeId": "thirdparty", | ||
}, | ||
) | ||
res_json = res.json() | ||
assert res_json["status"] == "NO_USER_FOUND_ERROR" | ||
|
||
res = app.get( | ||
url="/auth/dashboard/api/user", | ||
params={ | ||
"userId": pluser.user.user_id, | ||
"recipeId": "thirdparty", | ||
rishabhpoddar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
) | ||
res_json = res.json() | ||
assert res_json["status"] == "OK" | ||
assert res_json["user"]["id"] == pluser.user.user_id |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.