rajivharlalka
03/27/2022, 6:46 PMpython
def override_thirdpartyemailpassword_apis(original_implementation: APIInterface):
original_emailpassword_sign_up_post = original_implementation.emailpassword_sign_up_post
async def emailpassword_sign_up_post(form_fields: List[FormField],api_options: EmailPasswordAPIOptions, user_context: Dict[str, Any]):
body=await api_options.request.json()
user_context["role"] = body["role"]
return await original_emailpassword_sign_up_post(form_fields, api_options, user_context)
original_implementation.emailpassword_sign_up_post = emailpassword_sign_up_post
return original_implementation
def override_functions(original_implementation):
original_implementation_create_new_session = original_implementation.create_new_session
async def create_new_session(request, user_id,
access_token_payload,
session_data, user_context):
....
....
print(user_context)
role = user_id;
access_token_payload["role"] = role
return await original_implementation_create_new_session(request, user_id, access_token_payload, session_data, user_context)
original_implementation.create_new_session = create_new_session
return original_implementation
On hitting the sign up api, not getting the user_context populated with the role object. But the session is getting created after the user_context is getting defined through the overriding function. Is there I getting wrong in the workflow of auth 🤔