Hello here, is it possible to implement number cod...
# support-questions
d
Hello here, is it possible to implement number code for email verification?
r
hey @dhatGuy
Yes. This is possible. However, it would require some customisation from your side: - First, you want to provide the callback to send the email yourself. This callback takes the email verification link as one of its inputs. - In this callback, you want to extract the one time use code from the link (it's a query param in the link), and save it against some random number code (a 5 or 6 digit code) in your db. So in your db, there will be a map from OTP code => email verification code. - In the email, you want to send the OTP code to the user. - When they enter the code in the app, you can call the email verification consume code API that we expose via our backend SDK. - Finally, you want to override that API on the backend SDK side to fetch the actual email verification code from the input OTP, and then call the original implementation with it.
I can probably make a demo app for this if you open an issue about this on our github.
d
Okay, thanks. I'll give it a try first and get back to you
r
cool! please feel free to ask more related questions in this thread
d
I've tried to do it but didn't get it to work
I'll open an issue
r
sounds good!
d
@rp I've been able to make it work
Do I need to store the rid too?
r
nice!
> Do I need to store the rid too? Not needed.
d
alright
j
Quick point on your suggested implementation @rp There is nothing holding me back from saving that email verification code otp mapping inside the users metadata, right? Since the user must be logged in to submit the otp, I'll always have the user metadata to look it up. Or is there something I'm overlooking in the implementation details of the user metadata feature, that makes it ill-fitted for this?
r
You could save that in the user metadata indeed. I think that would work. Just one point is that the user can generate multiple email verification links at the same time and all of them get revoked as soon as the user consumes even one of them.
j
Gotcha! Thx for the insight.
b
@rp hi, is there any sample code for email verification via OTP available?
@rp and also if i need to start fresh, do i have to customize UI fully to have additional OTP input page instead of email verification notice page?
r
hey @bian here is an example: https://github.com/supertokens/supertokens-auth-react/tree/master/examples/with-emailverification-with-otp I believe this answers both your questions.
b
thanks!