-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfe84f5
commit fa03181
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -321,6 +321,30 @@ async def get_user_info( # pylint: disable=no-self-use | |
return oi | ||
|
||
|
||
def mock_provider_override(oi: Provider) -> Provider: | ||
async def get_user_info( | ||
oauth_tokens: Dict[str, Any], | ||
user_context: Dict[str, Any], | ||
) -> UserInfo: | ||
user_id = oauth_tokens.get("userId", "user") | ||
email = oauth_tokens.get("email", "[email protected]") | ||
is_verified = oauth_tokens.get("isVerified", "true").lower() != "false" | ||
|
||
return UserInfo( | ||
user_id, UserInfoEmail(email, is_verified), raw_user_info_from_provider=None | ||
) | ||
|
||
async def exchange_auth_code_for_oauth_tokens( | ||
redirect_uri_info: RedirectUriInfo, | ||
user_context: Dict[str, Any], | ||
) -> Dict[str, Any]: | ||
return redirect_uri_info.redirect_uri_query_params | ||
|
||
oi.exchange_auth_code_for_oauth_tokens = exchange_auth_code_for_oauth_tokens | ||
oi.get_user_info = get_user_info | ||
return oi | ||
|
||
|
||
def custom_init(): | ||
global contact_method | ||
global flow_type | ||
|
@@ -713,6 +737,21 @@ async def resend_code_post( | |
), | ||
override=auth0_provider_override, | ||
), | ||
thirdparty.ProviderInput( | ||
config=thirdparty.ProviderConfig( | ||
third_party_id="mock-provider", | ||
name="Mock Provider", | ||
authorization_endpoint=get_website_domain() + "/mockProvider/auth", | ||
token_endpoint=get_website_domain() + "/mockProvider/token", | ||
clients=[ | ||
thirdparty.ProviderClientConfig( | ||
client_id="supertokens", | ||
client_secret="", | ||
) | ||
], | ||
), | ||
override=mock_provider_override, | ||
), | ||
] | ||
|
||
global enabled_providers | ||
|
@@ -1386,6 +1425,7 @@ def index(_: str): | |
|
||
@app.errorhandler(Exception) # type: ignore | ||
def all_exception_handler(e: Exception): | ||
print(e) | ||
return "Error", 500 | ||
|
||
|
||
|