Can I assign an email to an exisiting user? So I ...
# support-questions
w
Can I assign an email to an exisiting user? So I want users to sign up using the phone otp and verify email with OTP. how can I do this? later they can signin using either. passwordless
r
hey @web3geek . i don't think i understand the flow clearly. Can you explain again?
w
Hey @rp So what I have is first the user signups using phone and otp then I take their email. now I want to verify this email with otp. If I use the /code API with email it will generate a new user-id, right? So basically what I'm looking for is verify email with otp and make sure that it's assigned to the actual userId so he can later login with email or phone and we know it's the same user
r
Ah I see. To do that, you can associate the new email with the same user Id before generating the code.
There should be a function like Passwordless.updateUserInfo using which you can associate the email to this user.
So what you should do is, let the code be consumed and let it create a new user. Once the new user is created, you can delete the new user and associate the email with the existing userId.
And you can do all this via overriding of consumeCode API
finally, to prevent a new session from being created, you can check if a session exists in the api before calling the original implementation, and then add the existing session to the userContext object. Then in the createNewSession override, you can check if a session exists in the userContext and if it does, just return that existing session
If you want, I can send over some code for this in sometime
w
yes please. that would be great. thanks a lot
r
hey @web3geek
c
How would I use this? If I go to the login route it just sends me back to the app if I am logged in.
And if I log out then I don't have the session
r
@CaptainPhoton you can override the doesSessionExist function on the frontend (session recipe) to return false for the route on which you want to show the phone number input UI
c
Not sure I follow. Can I override it elsewhere than in the init?
r
you will have to override it in init
on the frontend
c
thanks I'll check it out!
userContext is empty in the doesSessionExist function :/ Setting it from the route like in the example:
r
Yea. You can set it like that
or in the override for doesSessionExistm you can check the current path of the url, and if it's /auth-info, then return
false
c
but it's empty 😕 input.userContext is an empty object here:
okay I'll check the URL then
r
which version of the supertokens-auth-react SDK?
c
0.23.2 I believe
r
right. That should work then
hmm
c
(it should return false there, I fixed it in the code)
r
so the doesSessionExist's userContext can be empty if it's being called by other places
c
I have to check the url then?
r
you can, but the context passing you did should work too
c
it would be nice
r
if it doesn't can you open an issue about it in our repo?
c
okay I'll do that!
r
thanks
c
It would be easier with a Supertokens interface where a logged-in user could change their email and phone number
or link to a thirdparty account
r
yea agreed. We will add them at somepoint for sure. If you like, you can open a feature request for this
c
would be great 😄
r
thanks! Will have a look
3 Views