Hey <@498057949541826571> I am using ThirdPartyPas...
# support-questions-legacy
s
Hey @rp_st I am using ThirdPartyPasswordless recipe, I am overiding createCodePOST, to check if the user exists in my db, otherwise I am creating a new user. If the user exists then I simply want to show the OTP screen, if the user doesn't exist, I'll create the user in my db, and I want to log in the user automatically(skipping the otp screen step). Can you help me out with this?
r
hey @showtim33 yea. So which part of the flow do you need help with?
s
"I want to log in the user automatically"
basically this
Need to log in the user/create session for the new user programattically
r
right. So can I see your override code?
s
Copy code
createCodePOST: async (input:
            { userContext: { request: any; }; options: { req: { original: any; }; }; }) => {
              // eslint-disable-next-line no-param-reassign
              
              if(newUser) {
                //do some logic
                // login the user/create session automatically.
              }
              return originalImplementation.createCodePOST(input);
            },
@rp_st roughly this
r
So to know if a user already exists, you can get the input.email and query the recipe using
getUserByEmail
. If that returns undefined, it means the user deos not exist.
s
I need help with logging the user programatically, bypassing the input otp screen. @rp_st
r
if the user exists, then you can essentially, call the
await Session.createNewSession
function with the user's ID and the response object. You can return some fake API response which conforms with the return type of the function
s
Ok yeah awesome, i think await Session.createNewSession this solves it.
r
yup
s
@rp_st "user's ID and the response object. " where to get this res object?
await Session.createNewSession(res, userId);
r
it should be
input.options.res