https://supertokens.com/ logo
Title
p

Pritish S

02/04/2023, 9:11 AM
Hello everyone. Can someone direct me where the bug could be? I am trying to override the function
emailpassword_sign_up
in my python code by using function override. I am using Python FastAPI library. I have been getting the following error when I override function
TypeError: override_thirdpartyemailpassword_functions.<locals>.email_sign_up() missing 1 required positional argument: 'user_context'
My understanding is that
user_context: Dict[str, Any]
should be passed as a dependency by FastAPI. It works when I override
thirdparty_sign_in_up
function. I am not sure why it does not work for
emailpassword_sign_up
.
r

rp

02/04/2023, 10:36 AM
Hey @Pritish S
Can I see the code for how you have overriden the functions?
p

Pritish S

02/04/2023, 10:49 AM
Yes, here it is -
python
def override_thirdpartyemailpassword_functions(original_implementation: RecipeInterface):
    original_sign_in_up = original_implementation.thirdparty_sign_in_up
    original_emailpassword_sign_up = original_implementation.emailpassword_sign_up

    async def thirdparty_sign_in_up(third_party_id: str, third_party_user_id: str, email: str,user_context: Dict[str, Any]):
        result =  await original_sign_in_up(third_party_id, third_party_user_id, email, user_context)
        if isinstance(result, ThirdPartySignInUpOkResult):
            uid=result.user.user_id
            email=result.user.email
            timeJoined=result.user.time_joined

            print("Functions.override chl rha hai")
            print(uid)
            print("Functions.override chlgya")

            if result.created_new_user:
                print("Third Party User Signed Up abhi function.override chla hai",result.user.email)
                mongo_id = dbOps.addToMyDbThirdParty(uid,email,timeJoined)
                result.user.user_id=mongo_id
                await create_user_id_mapping(uid, mongo_id ,force=True)
                print("Himanshu ",result.user.user_id)
                

            else:
                print("Third Party User already signedIn",result.user.email)
        
        return result
python



    async def email_sign_up(self, email: str, password: str, user_context: Dict[str, Any]):
        print("Into the function")
        result =  await original_emailpassword_sign_up(email,password,user_context)
        print(a)
        if isinstance(result, EmailPasswordSignUpOkResult):
            uid=result.user.user_id
            email=result.user.email
            timeJoined=result.user.time_joined
            print(uid)
            print("Email Password User Signed Up abhi function.override chla hai")
            mongo_id = dbOps.addToMyDbThirdParty(uid,email,timeJoined)
            result.user.user_id=mongo_id
            await create_user_id_mapping(uid, mongo_id ,force=True)
            print("Himanshu ",result.user.user_id)
        return result
    
    original_implementation.emailpassword_sign_up = email_sign_up
    original_implementation.thirdparty_sign_in_up = thirdparty_sign_in_up
    
    return original_implementation
r

rp

02/04/2023, 10:51 AM
remove the
self
arg from
email_sign_up
p

Pritish S

02/04/2023, 10:54 AM
Thank you so much @rp.
r

rp

02/04/2023, 11:01 AM
great!