Bailey
11/23/2022, 7:06 PMpasswordless
phone number input after sign up. I'm overriding emailpassword's signUpPOST
function by calling:
- signUp
(/recipe/emailpassword)
- createNewSession
(/recipe/session)
signUpPOST: async function (input) {
let signup = await signUp(
email,
password,
input.userContext
);
if (signup.status === 'OK') {
// Create database user
...
// Create session
return createNewSession(
input.options.res,
signup.user.id,
undefined,
undefined,
input.userContext
);
}
}
I'm unsure if the input
variables I'm passing here are correct, or if there is another recipe function I should be calling.
The session and user seem to be created properly, but the frontend requires a manual refresh in order to reach the passwordless
Second factor auth (phone number input page). Without a manual refresh, the frontend says to sign in instead since the email is already in use.rp_st
11/24/2022, 4:17 AMrp_st
11/24/2022, 4:18 AMBailey
11/24/2022, 2:43 PM{
status: 'OK',
user: {
email: 'b.....@hotmail.ca',
id: 'fb7aaa17-50aa-4074-8297-5de0947ad2f8',
timeJoined: 1669300965495
}
}
Bailey
11/24/2022, 3:13 PM{
originalSessionClass: Session {
sessionHandle: '7def5259-9c0c-49c4-aee0-d6b90bd44aa2',
userId: 'fb7aaa17-50aa-4074-8297-5de0947ad2f8',
userDataInAccessToken: {
'st-ev': {
v: false,
t: 1669301109625
},
'2fa-completed': {
v: false,
t: 1669301109753
},
username: 'test5',
verified: false,
role: 'User',
jwt: '...',
_jwtPName: 'jwt'
},
res: ExpressResponse {
wrapperUsed: true,
sendHTMLResponse: [Function (anonymous)],
setHeader: [Function (anonymous)],
setCookie: [Function (anonymous)],
setStatusCode: [Function (anonymous)],
sendJSONResponse: [Function (anonymous)],
original: [ServerResponse],
response: [ServerResponse],
statusCode: 200
},
accessToken: '...',
helpers: {
querier: [Querier],
updateJwtSigningPublicKeyInfo: [Function: updateJwtSigningPublicKeyInfo],
getHandshakeInfo: [Function: getHandshakeInfo],
config: [Object],
getRecipeImpl: [Function (anonymous)]
}
},
openIdRecipeImplementation: {
getOpenIdDiscoveryConfiguration: [Function: bound getOpenIdDiscoveryConfiguration],
createJWT: [Function: bound createJWT],
getJWKS: [Function: bound getJWKS],
_call: [Function: bound _call]
}
}
Bailey
11/24/2022, 3:57 PMrecipe/emailpassword/signUp()
and recipe/session/createNewSession()
the only functions I should need to call to replicate the signUpPost override?rp_st
11/24/2022, 5:16 PMrp_st
11/24/2022, 5:16 PMrp_st
11/24/2022, 5:17 PMrp_st
11/24/2022, 5:21 PMBailey
11/24/2022, 5:47 PM/verify-email
, and after that is completed the frontend goes to the 2fa passwordless process.
When I use the standard oI.signUpPOST(input)
the frontend acts normally, redirecting me to /verify-email
automatically.Bailey
11/24/2022, 5:54 PMBailey
11/24/2022, 6:41 PMconst { signUp } = require('supertokens-node/recipe/emailpassword');
const { createNewSession } = require('supertokens-node/recipe/session');
...
EmailPassword.init({
override: {
apis: (oI) => {
return {
...oI,
signUpPOST: async function (input) {
// Supertokens signup
let signup = await signUp(
input.formFields[0].value,
input.formFields[1].value,
input.userContext
);
// Create database user
if (signup.status === 'OK') {
// Create session
return await createNewSession(
input.options.res,
signup.user.id,
undefined,
undefined,
input.userContext
);
}
return {
status: 'GENERAL_ERROR',
message: 'Something went wrong'
}
},
};
},
}
}),
Bailey
11/24/2022, 7:02 PMsignUpPOST
function. signUpPOST
is supposed to return an object like this and not just the session:
return {
status: "OK",
session, // createNewSession()
user: signup.user // signUp().user
};
rp_st
11/25/2022, 2:40 AM