Is there a way to create an "always valid" OTP for testing?
I am currently migrating from clerk to better-auth and I am wondering if there is a way to create OTPs that are always valid
Solution:Jump to solution
GitHub
chore(email-otp): Allow returning undefined in
generateOTP by pin...Right now you're forced to return an OTP value in the generateOTP function as part of the email-otp plugin. In some cases you may just want to return an OTP under a specific case, and just ...
10 Replies
2fa otps? or email-otps?
Email otp
Do you mean an OTP that once verified remains valid? or an otp that doesn't expire?
With clerk I could use 424242 as otp for any test email on the dev environment
I am wondering if I can replicate this with better auth
you can probably do this by passing
generateOTP fn into the emaiil otp plugin options
and just return 424242 if on devAh interesting, I will try that
@Ping worked perfectly thanks again. However I had to search a bit until I found your
createRandomStringGenerator utility function because I wanted to stay as close to your implementation as possible. Maybe its a good idea to generate a OTP in all cases and allow the user to intercept it. Something along thos lines:
I am not sure about the implications, just my two cents.Thanks for the feedback!
Thanks for the amazing project, recommending it everywhere!
Solution
GitHub
chore(email-otp): Allow returning undefined in
generateOTP by pin...Right now you're forced to return an OTP value in the generateOTP function as part of the email-otp plugin. In some cases you may just want to return an OTP under a specific case, and just ...
Wow that was fast 🤩