Hi everyone, I am trying to input first_name and l...
# support-questions-legacy
j
Hi everyone, I am trying to input first_name and last_name as part of emailpassword signup. I tried adding a first_name and last_name InputFormField and ran a simple curl to post a signup with those values but I dont think they are coming through. If I view the user management dashboard I see "FEATURE_NOT_ENABLED" for both first name and last name. I get the feeling that this is not the right way to set it? Anyone has any idea what I may have done wrongly?
h
Did you add that in the signUpPost method of whatever recipe you are using ?
j
I have something like this mailpassword.init( sign_up_feature=emailpassword.InputSignUpFeature( form_fields=[ InputFormField(id='email', validate=validate_phone), InputFormField(id='password', validate=validate_password), InputFormField(id='name'), InputFormField(id='first_name') ] ) ),
I tried name and first_name but it doesnt accept it, is the id different for user metadata? @hehohesda_12345
r
you need to enable the user metadata recipe and add
first_name
and
last_name
metadata fields to that user.
j
Thanks @rp_st after enabling the feature how do I enable formFields to input this information? I tried the following but it does not seem to work emailpassword.init( sign_up_feature=emailpassword.InputSignUpFeature( form_fields=[ InputFormField(id='email'), InputFormField(id='password', validate=validate_password), InputFormField(id='first_name'), InputFormField(id='last_name') ] ) ),
r
See our docs for user metadata and sign up override please.
j
@rp_st sorry I really tried but I am looking at pages like https://supertokens.com/docs/emailpassword/common-customizations/usermetadata/store-data and https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/signup-form/adding-fields but really can't figure out what needs to be done to get the user metadata during signup
r
So see this: https://supertokens.com/docs/emailpassword/common-customizations/handling-signup-success This allows you to do operations post sign up. Then in the function, you can call the usermetadata functions to save info against the user ID
j
thanks real much @rp_st managed to get this to work. In any case someone else is looking to do the same you can do something like this:
Copy code
def override_email_password_apis(original_implementation: APIInterface):
    original_sign_up_post = original_implementation.sign_up_post

    async def sign_up_post(form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]):
        # First we call the original implementation of signInPOST.
        response = await original_sign_up_post(form_fields, api_options, user_context)

        # Post sign up response, we check if it was successful
        if isinstance(response, SignUpPostOkResult):
            user_id = response.user.user_id
            
            # TODO: post sign up logic

            await update_user_metadata(user_id, {
                "first_name": form_fields[2].value,
                "last_name": form_fields[3].value
            })

        return response

    original_implementation.sign_up_post = sign_up_post
    return original_implementation
then in your sign_up_feature you can set formfields like this:
Copy code
sign_up_feature=emailpassword.InputSignUpFeature(
                form_fields=[
                    InputFormField(id='email'), 
                    InputFormField(id='password'),
                    InputFormField(id='first_name'),
                    InputFormField(id='last_name')
                ]
            )
r
thanks @javierwong !
135 Views