https://supertokens.com/ logo
c

CaptainPhoton

06/30/2022, 5:56 PM
What's the best way to get the user email here?
Copy code
consumeCode: async function (input) {
              let { deviceId, preAuthSessionId, userInputCode } = input;
              
              let user = getUserSomehow(deviceId, preAuthSessionId, or userInputCode);

              console.log(user);

              /*if (email) {
                await preventUserSignUpIfTheyAlreadyExist(email);
              }*/

              return originalImplementation.consumeCode(input);
            }
Do I need to put it in userContext? If so, where do I do that?
I guess createCode then
r

rp

06/30/2022, 5:59 PM
There is a function in passwordless recipe called listCodesByPreAuthSessionId
That function takes as input the preAuthSessionId which is in the input object
And returns an object which has the email or phone that was submitted by the user when creating the code
c

CaptainPhoton

06/30/2022, 6:00 PM
ooh! great, thanks πŸ˜„
Hmm it doesn't show the correct error message. It worked for the thirdparty login case
it does catch the error, and when I log the error the message is correct
r

rp

06/30/2022, 6:11 PM
The api spec for that api doesn’t return field_error
Instead, it returns GENERAL_ERROR
c

CaptainPhoton

06/30/2022, 6:12 PM
ah, gotcha πŸ˜„
r

rp

06/30/2022, 6:12 PM
and a message: string
See the types of the function you are overriding please
c

CaptainPhoton

06/30/2022, 6:12 PM
will try! thanks
I do appreciate that it is very well typed, but this is sadly not a typescript project so types are not THAT readily available to me. The editor does show that consumeCodePOST can return a GeneralError, but not what the shape is. And I assumed that it was the same as the thirdPartySignInUp case
r

rp

06/30/2022, 6:25 PM
Ah right. Fair enough.
Hope it works now πŸ™‚
c

CaptainPhoton

06/30/2022, 6:56 PM
yes it seems to work!
r

rp

06/30/2022, 6:56 PM
Great.
c

CaptainPhoton

06/30/2022, 6:57 PM
true account linking is coming soon though, right? I saw something related to that in issues and PR's πŸ˜„
r

rp

06/30/2022, 6:57 PM
Yeaaaaa. 1-2 months maybe
c

CaptainPhoton

06/30/2022, 6:57 PM
cool, this will do until then
r

rp

06/30/2022, 6:57 PM
Allow you to automatically link accounts as well and prevent any account linking (similar to what you made right now)
Or rather prevent creation of separate accounts with same identifier
c

CaptainPhoton

06/30/2022, 6:58 PM
yeah, that's the main thing
Don't want users ending up with several separate accounts, very bad UX
r

rp

06/30/2022, 6:59 PM
Makes sense
2 Views