Is it possible to give custom userId to supertoken...
# support-questions-legacy
m
Is it possible to give custom userId to supertokens.? I know supertokens uses uuid. I was taking a look at the override functions. Wondering if I can pregenerate the user_id that will be used in supertokens table
r
hey @muhajirdev yes it is
@jscyo can help here
j
Hey @muhajirdev we provide a feature called userId mapping which allows you to map a custom userId to a supertokens user.
Could you let me know what recipe you are using on the backend SDK?
You can take a look at the node SDK function for creating a mapping https://supertokens.com/docs/nodejs/modules/index.html#createUserIdMapping
m
Yes I am using ThirdPartypasswordless
j
Right, so you can pass the customID and supertokens userId for your user to the
createUserIdMapping
function and now you should be able to interact with all SuperTokens APIs with the customID.
m
Is there any example in the website?
I found about auth0
But I still donโ€™t fully understand it yet
j
Yup we dont have dedicated docs yet, but I will write up a code snippet. I am assuming you are looking to migrate users right?
m
yeah, would be great if you can write the code snippet. I will see what I can do from there
You can assume I am doing user migration @jscyo
j
Hey you can take a look at this snippet:
It's a modified version of our Auth0 migration guide https://supertokens.com/docs/thirdpartypasswordless/migration/from-auth0/account-migration/modifications-to-login but is updated to use the userIdMapping feature
m
I see, after this. Everytime I call
getUserById(userId: string)
I can use the customId ? @jscyo ?
j
Yup exactly
m
awesome, got it.
j
All responses which also return userInfo will also have the custom Id
m
so the supertokens userId will basically be hidden right
I will only interact the customId after that
j
Yup
m
okay, I think I understand it - if the user exist in the db - call the origin implementation - if it's a newly createdUser - call the createUserIdMapping and use customId in response
I wonder how will it looks for signin with google or apple
j
Hey so I have updated the snippet to include thirdparty migration also
I've made some changes so please refresh
m
okay, got it. so, I am assuming you're tying to use input.thirdPartyUserId here right what is thirdPartyUserId?
is it the google account id?
and thirdPartyId is like "google" string?
j
Yup that is correct
m
i see, got it got it
that's very helpful
thank you very much
j
Happy to help๐Ÿ˜„
m
haha, I wish I can give 5/5 stars ๐Ÿ˜„
hey @jscyo , one more question if you don't mind. Is there a way to print the magic link or otp code in the terminal. gonna need it for testing environment ๐Ÿ˜†
and also now that I am migrating away from email + password -> passwordlesss + social login. I am also figuring out, how to setup reproducible and easy way for QA to test the app
r
> Is there a way to print the magic link or otp code in the terminal. Yea.. checkoiut emaildelivery -> custom method section
m
ah okay, found it.
thanks @rp_st
@rp_st , so
consumeCode
is only called when user manually input the number, or it's also called when user click the magic link? and what is the different with
passwordlessSignInUp
?
I see both returns
Promise
that contains
createdNewUser
r
consumeCode is called in both instances
> and what is the different with passwordlessSignInUp ? What do you mean?
r
oh right. passwordlessSignInUp is just a helper function which creates a code and consumes it
without actually sending the user the otp / magic link
useful for user migration
m
ahh got it
thanks @rp_st
2 Views