https://supertokens.com/ logo
Title
d

DarkPhoenix

01/12/2023, 1:14 PM
Is it possible to resend otp via Phone. I want to send OTP via sms at first, then show resend otp via phone as an option along with resend sms
r

rp

01/12/2023, 1:36 PM
hey @DarkPhoenix
it is possible. How have you setup the passwordless flow.
our pre built UI already has the resend button. And for custom UI, we have docs that show how to implement resend. Have you seen those?
d

DarkPhoenix

01/12/2023, 3:15 PM
Yes
I want to have both Resend OTP & Resend OTP(Call) option
We have implemented resend OTP via SMS . It's working I just want to know how to resend OTP via call
r

rp

01/12/2023, 3:24 PM
hmm. You can always override the sendSms function on the backend and do it via a call i guess.
r

rp

01/12/2023, 3:26 PM
?
d

DarkPhoenix

01/12/2023, 3:27 PM
Can i know what changes should be done here?
r

rp

01/12/2023, 3:28 PM
you can modify the user context in the API for resend code before calling the orginal impementation and then read the userContext in the sendSms function to know if you should do it via a call or via SMS
d

DarkPhoenix

01/12/2023, 3:30 PM
ok
I added the userContext in both sendSms & resendCode function. But the value of userContext is undefined in backend
I checked the network request & it only has phoneNumber. The userContext is not sent
r

rp

02/03/2023, 12:00 PM
userContext is to be added in backend api override
d

DarkPhoenix

02/03/2023, 2:56 PM
yes i did
i tried to console the useContext
it has nothing other than request
r

rp

02/03/2023, 3:24 PM
where are you modifying the userContext?
d

DarkPhoenix

02/03/2023, 3:40 PM
createCode()
r

rp

02/03/2023, 3:40 PM
right. So userContext is not transported to the backend from the frontend..
you need to modify the userContext in the backend api override
if you want to communicate from frontend to backend, you can use the pre api hook and modify the request body
d

DarkPhoenix

02/03/2023, 3:41 PM
is there any docs?
r

rp

02/03/2023, 3:42 PM
yea. Search for pre api hook in our docs ๐Ÿ™‚
d

DarkPhoenix

02/03/2023, 3:42 PM
ok
Hey I fixed it. Now it works๐Ÿ™‚