syntaxerror1322
02/14/2023, 7:59 PMcreateCode
function? Currently it doesn't allow me to pass custom fields.rp_st
02/15/2023, 5:27 AMsyntaxerror1322
02/15/2023, 1:53 PMsyntaxerror1322
02/15/2023, 1:53 PMrp_st
02/15/2023, 1:58 PMsyntaxerror1322
02/15/2023, 2:17 PMrp_st
02/15/2023, 2:20 PMgetting field via defaultContext := (*userContext)["_default"]
is the right way of doing it.
We plan on adding helper functions to make sense of the userContext soon.syntaxerror1322
02/15/2023, 2:22 PMrp_st
02/15/2023, 2:23 PMrp_st
02/15/2023, 2:24 PMsyntaxerror1322
02/15/2023, 2:24 PMNamratha
04/11/2023, 1:05 PMNamratha
04/11/2023, 1:10 PMrp_st
04/11/2023, 1:23 PMNamratha
04/11/2023, 1:29 PMrp_st
04/11/2023, 1:35 PMNamratha
04/11/2023, 1:36 PMrp_st
04/11/2023, 1:36 PMNamratha
04/11/2023, 1:38 PMrp_st
04/11/2023, 1:38 PMrp_st
04/11/2023, 1:38 PMNamratha
04/11/2023, 1:38 PMNamratha
04/11/2023, 1:39 PMrp_st
04/11/2023, 1:40 PMrp_st
04/11/2023, 1:40 PMrp_st
04/11/2023, 1:57 PMpython
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import passwordless
from supertokens_python.recipe.passwordless.interfaces import APIInterface, APIOptions, ConsumeCodePostOkResult
from typing import Union, Dict, Any
def override_passwordless_apis(original_implementation: APIInterface):
original_consume_code_post = original_implementation.consume_code_post
async def consume_code_post(pre_auth_session_id: str,
user_input_code: Union[str, None],
device_id: Union[str, None],
link_code: Union[str, None],
api_options: APIOptions,
user_context: Dict[str, Any]):
# Access the custom_field parameter from the user_context dictionary
custom_field = await api_options.request.json().get("custom_field")
# First we call the original implementation of consume_code_post.
response = await original_consume_code_post(pre_auth_session_id, user_input_code, device_id, link_code, api_options, user_context)
# Post sign up response, we check if it was successful
if isinstance(response, ConsumeCodePostOkResult):
user = response.user
if response.created_new_user:
# TODO: post sign up logic
else:
# TODO: post sign in logic
return response
# Update the original implementation with the new consume_code_post function
original_implementation.consume_code_post = consume_code_post
return original_implementation
init(InputAppInfo(...))
passwordless.init({
"override": {
"apis": override_passwordless_apis
}
})
rp_st
04/11/2023, 1:58 PMcustom_field = await api_options.request.json().get("custom_field")
To get the custom_field. Im not 100% sure if the above is full accurate, but you get the idea..Namratha
04/12/2023, 4:32 AM