CaptainPhoton
06/18/2022, 12:52 PMrp
06/18/2022, 12:56 PMCaptainPhoton
06/18/2022, 1:11 PMrp
06/18/2022, 1:14 PMThirdPartyPasswordless.init({
/* Your other config */
override: {
emailVerification: {
functions: (oI) => {
return {
...oI,
isEmailVerified: async function (input) {
return {
status: "OK",
fetchResponse: new Response(),
isVerified: false
}
}
}
}
}
}
})
This way, you are telling the email verification component that the email is not verified by overriding the isEmailVerified
component.CaptainPhoton
06/18/2022, 3:24 PMrp
06/18/2022, 3:34 PMCaptainPhoton
06/18/2022, 3:38 PMrp
06/18/2022, 3:40 PMCaptainPhoton
06/18/2022, 3:46 PMrp
06/18/2022, 3:50 PMCaptainPhoton
06/18/2022, 3:51 PMrp
06/19/2022, 6:52 AMCaptainPhoton
06/19/2022, 6:52 AMrp
06/19/2022, 6:54 AMCaptainPhoton
06/19/2022, 7:07 AMrp
06/19/2022, 7:10 AMCaptainPhoton
06/19/2022, 7:10 AMrp
06/19/2022, 7:11 AMCaptainPhoton
06/19/2022, 7:13 AMrp
06/19/2022, 7:16 AMEmailVerification
in the recipeList on the backend.
I know that this can be slightly confusing, but in short, the thirdpartypasswordless recipe has its own instance of the emailverification recipe inside it which has been modified to treat all passwordless users as if their email is verified. So to hack around it, we create our own EmailVerification
recipe instance and use that.
We will make this easier in a few weeks, but for now, you can try this.CaptainPhoton
06/19/2022, 7:31 AMrp
06/19/2022, 7:55 AMCaptainPhoton
06/19/2022, 7:56 AMCaptainPhoton
06/19/2022, 7:56 AMrp
06/19/2022, 7:57 AMThirdPartyPasswordlessAuth
?CaptainPhoton
06/19/2022, 7:58 AMrp
06/19/2022, 7:58 AMCaptainPhoton
06/19/2022, 7:58 AMrp
06/19/2022, 7:58 AMThirdPartyPasswordlessAuth
only for the specific routes you want to check for session inCaptainPhoton
06/19/2022, 8:01 AMrp
06/19/2022, 8:01 AM<SessionAuth requireAuth={false}>...</SessionAuth>
wrapper insteadimport {SessionAuth} from "supertokens-auth-react/recipe/session"
CaptainPhoton
06/19/2022, 8:02 AMrp
06/19/2022, 8:04 AMCaptainPhoton
06/19/2022, 8:11 AMrp
06/19/2022, 8:16 AMCaptainPhoton
06/19/2022, 8:54 AMcreateAndSendCustomEmail
function either ๐คrp
06/19/2022, 8:54 AMCaptainPhoton
06/19/2022, 8:55 AMcreateAndSendCustomEmail
signature is different between the ThirdpartyPasswordless and the emailverification reciperp
06/19/2022, 8:55 AMCaptainPhoton
06/19/2022, 8:55 AMrp
06/19/2022, 8:59 AMCaptainPhoton
06/19/2022, 9:00 AMrp
06/19/2022, 9:02 AMgetEmailForUserId
not logging is fine. Can I see how you have given sendVerifyEmail
to the thirdpartypasswordless recipe?CaptainPhoton
06/19/2022, 9:04 AMrp
06/19/2022, 9:05 AMCaptainPhoton
06/19/2022, 9:07 AMrp
06/19/2022, 9:09 AMemailVerificationFeature
like so:
ts
ThirdPartyPasswordless.init({
flowType: 'USER_INPUT_CODE_AND_MAGIC_LINK',
contactMethod: 'EMAIL_OR_PHONE',
providers: [...],
createAndSendCustomEmail: sendAuthEmail,
createAndSendCustomTextMessage: sendAuthSms,
emailVerificationFeature: {
createAndSendCustomEmail: sendVerifyEmail // maybe the types don't match up, but you need to provide a function here to send an email verification email.
}
override: {
...
}
}),
EmailVerification.init({
getEmailForUserId: async (userId) => {
let user = await ThirdPartyPasswordless.getUserById(userId);
if (user?.email) {
return user.email;
}
throw new Error('Should never come here');
},
}),
That is, we remove the createAndSendCustomEmail
from there.CaptainPhoton
06/19/2022, 9:10 AMrp
06/19/2022, 9:11 AMCaptainPhoton
06/19/2022, 9:11 AMrp
06/19/2022, 9:11 AMCaptainPhoton
06/19/2022, 9:15 AMrp
06/19/2022, 9:16 AMCaptainPhoton
06/19/2022, 9:18 AMrp
06/19/2022, 9:18 AMlet ThirdPartyPasswordlessRaw = require("supertokens-node/lib/build/recipe/thirdpartypasswordless/recipe").default;
ThirdPartyPasswordlessRaw.getInstanceOrThrowError().emailVerificationRecipe.config.getEmailForUserId = async (userId) => {
let user = await ThirdPartyPasswordless.getUserById(userId);
if (user !== undefined && user.email !== undefined) {
return user.email;
}
return "";
};
Otherwise the email that's send to your callback to send the email is an incorrect one.CaptainPhoton
06/19/2022, 2:43 PMrp
06/19/2022, 2:44 PMCaptainPhoton
06/19/2022, 2:51 PMrp
06/19/2022, 2:51 PMCaptainPhoton
06/19/2022, 3:07 PMrp
06/19/2022, 3:07 PMCaptainPhoton
06/19/2022, 4:33 PM{
email: '...',
phoneNumber: '...',
id: '8cba10cf-6acd-4c07-b764-552fd75934a8',
timeJoined: 1654426540378
}
Link:
http://localhost:8080/login/verify-email?token=YWJmNmNhOTM5MDdhMGVkNzJmMzdhZWVmNWQyMGNjMzFjMTMyZmY3ZmU5MzljOTYxZDZkNDUzNjZiZDA3OWRkMmMyNmVmZGI0ZmMwZjIyYzBmYjc2M2UwZDBiMGZlOTA0&rid=thirdpartypasswordlessrp
06/19/2022, 4:35 PMCaptainPhoton
06/19/2022, 4:36 PMrp
06/19/2022, 4:37 PMCaptainPhoton
06/19/2022, 4:38 PMrp
06/19/2022, 4:39 PMCaptainPhoton
06/19/2022, 4:39 PMrp
06/19/2022, 4:40 PM