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]):
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):
_ = response.user.user_id
__ = response.user.email
_ = response.user.phone_number
if response.created_new_user:
res = await add_role_to_user("public",response.user.user_id, "role_name")
return response
original_implementation.consume_code_post = consume_code_post
return original_implementation