carlosbmC
Convex Community11mo ago
10 replies
carlosbm

Send params from signIn to sendVerificationRequest using ResendOTP

Hello team!

I'm trying to pass the language of the user when he signs in to the app so that I can send the verification OTP email in that language.

I'm not finding a way to do it.

What I have in my react-native:

await signIn("resend-otp", {
email: parsedEmail,
options: {
language: "en",
},
test: "test", // I was testing with this.
})

And this is the configured Resend provider:

export const ResendOTP = Email({
id: "resend-otp",
apiKey: process.env.AUTH_RESEND_KEY,
maxAge: 60 * 15, // 15 minutes
async generateVerificationToken() {
return generateRandomString(4, alphabet("0-9"))
},
async sendVerificationRequest(params) {
const { identifier: email, provider, token } = params
// Extract language from params.options if it exists, defaulting to "en"
const options = params as unknown as { options?: CustomOptions }
const language = options.options?.language || "en"
console.log("Params:", params)
console.log("Language:", language)
// Create i18n instance for fallback text
const t = createEmailI18n(language)

const resend = new ResendAPI(provider.apiKey)
const { error } = await resend.emails.send({
from: "Shifty <onboarding@test.com>",
to: [email],
subject: t("email.verification.subject"),
text: t("email.verification.code") + ": " + token,
react: ShiftyVerificationEmail({
verificationCode: token,
language: language as Language,
}),
})

if (error) {
throw new Error(JSON.stringify(error))
}
},
})


And here neither in Params logs or Language I can see the desired params.

Thanks in advance!

Let me know what I can do in this case.
Was this page helpful?