If it is not saved then we have to save the data manually in db. ST already saves some info in the d...
s
If it is not saved then we have to save the data manually in db. ST already saves some info in the db. Why not custom fields?. If we have to insert it manually, what is the correct way. Save the extra fields in the same table where the users some info already saved by ST
r
Hey @shahreaz0
You have to save it somewhere manually. You can either use our user metadata feature
Or then save it in your own db against the user id that we provide.
s
Metadata will be fine. can you give me some references where extra fields save in metadata
r
Which recipe are you using?
s
email password
s
Thanks man. I appreciate. Great work by you guys
Metadata will be shown in the dashboard right?
r
Yes
s
Ok
any code examples how to change user ID format
r
Hey
We use the
Supertokens.createUserIdMapping
function
Copy code
ThirdPartyEmailPassword.init({
    override: {
        functions: (oI) => {
            return {
                ...oI,
                emailPasswordSignUp: async function (input) {
                    let response = await oI.emailPasswordSignUp(input);
                    if (response.status === "OK") {
                        // sign up successful
                        const customUserId = "<Custom user ID>"
                        await Supertokens.createUserIdMapping({
                            superTokensUserId: response.user.id,
                            externalUserId: customUserId,
                        })
                        response.user.id = customUserId;
                    }
                    
                    return response;
                },
                thirdPartySignInUp: async function (input) {
                    let response = await oI.thirdPartySignInUp(input);
                    if (response.status === "OK" && response.createdNewUser) {
                        // sign up successful
                        const customUserId = "<Custom user ID>"
                        await Supertokens.createUserIdMapping({
                            superTokensUserId: response.user.id,
                            externalUserId: customUserId,
                        })
                        response.user.id = customUserId;
                    }
                    
                    return response;
                }
            }
        }
    }
})
s
Thanks man
2 Views