- Is it possible to provide user traits on signup?...
# support-questions-legacy
n
- Is it possible to provide user traits on signup? For example, we know their email if they subscibed to our newsletter, and then they signup with a Github account. We'd like to save the email as a user "email "property (or as a custom property)
r
Yes. You can associate any JSON object against a user ID. You can even store any info in their session's access token payload.
The only catch is that the JSON stored in the user metadata is only queryable via the userID of that user. If you want to instead index the metadata to query it some other way, then you should store in your own db against the userID.
n
Thanks! As a follow-up, is it possible to already create a user id on the first step (when they only subscribe), and pass this user id in the real signup process? We'd persist it in a cookie between these events
r
You can genertae your own user IDs whenever you like. And then when the sign up function is called, you can map the supertokens generated userID with your own userID immediately after. All future calls to supertokens for that user would use your generated user ID.
So yes, that would is possible 🙂
n
so effectively replacing the Supertokens-assigned id? Can you point me to the docs? Can't find this
r
well, that's the thing. We are currently writing docs for this feature since we released it just ~1 week ago. But here is the API you can call from your backend to SuperTokens core to create a mapping: https://app.swaggerhub.com/apis/supertokens/CDI/2.15.1#/UserIdMapping%20Recipe/userIdMappingCreateMapping
n
Is there a Go wrapper? Or can/should I do an http call directly?
r
the nodeJS SDK is updated to have a function that calls this API (https://github.com/supertokens/supertokens-node/blob/master/lib/ts/supertokens.ts#L226). And we are working on updating the go SDK to have the same function. But you can still get it to work by calling the core yourself instead.
> Or can/should I do an http call directly? You can do this.. and sometime next week we will update the go SDK to have a wrapper function too.
n
we can wait a week, not a problem 😄
r
fair enough.
n
Our requirements are still in flux, we decided that at this point we need a robust auth system instead of direct github login that we had before. So now we are collecting use-cases that we have and trying to predict what we may need, and evaluating auth solutions. This will take some time anyway
r
Makes sense. We are here to help 🙂
n
FWIW account linking is also important for us but we can probably live without it for a while. I see that it is being worked on, so it is good: https://github.com/supertokens/supertokens-core/issues/447
r
yup.. should be available within 2 months time I think. But in the meantime, you can implement a way to do prevent users from creating duplicate accounts across login methods similar to how we do for our own site.
n
how do you do it?
r
so we override the sign up APIs on the backend SDK side to check if the input email is already being used from other login methods. If it is, then we return a custom error to the frontend and show it on the UI.
n
we've noticed that github in most cases doesn't return an email, probably email sharing is not on by default.
r
right. So if other login methods are email based, how would you know if the same user has previously signed up using github anyway?
n
we want them to verify an email 🙂 let's continue in the other thread
2 Views