What's the best way to get the user email here? ``...
# support-questions
c
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
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
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
The api spec for that api doesn’t return field_error
Instead, it returns GENERAL_ERROR
c
ah, gotcha πŸ˜„
r
and a message: string
See the types of the function you are overriding please
c
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
Ah right. Fair enough.
Hope it works now πŸ™‚
c
yes it seems to work!
r
Great.
c
true account linking is coming soon though, right? I saw something related to that in issues and PR's πŸ˜„
r
Yeaaaaa. 1-2 months maybe
c
cool, this will do until then
r
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
yeah, that's the main thing
Don't want users ending up with several separate accounts, very bad UX
r
Makes sense
3 Views