#Manually create otp code
3 messages · Page 1 of 1 (latest)
Hi @sick kelp. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The knowledge sources do not provide a documented or supported way to manually create a verification (OTP) code for a user outside of the standard sign-in flow using Convex Auth. The typical approach is to trigger OTP generation and sending via the signIn function, which handles code creation, storage, and expiration automatically as part of the authentication flow OTPs setup.
If you need to generate a code manually (for example, for custom flows or admin actions), you would need to replicate the logic used in the provider's generateVerificationToken and sendVerificationRequest methods. For example, the ResendOTP provider uses generateRandomString to create a code and then sends it via email OTPs setup:
import { generateRandomString } from "@oslojs/crypto/random";
const alphabet = "0123456789";
const length = 8;
const code = generateRandomString(random, alphabet, length);
// You would then need to store and manage this code yourself
However, the knowledge sources do not describe how to insert this code into Convex Auth's verification storage or how to validate it later without using the signIn flow. This means you would need to implement your own storage and verification logic, which is not covered in the official documentation.