sendOtp function not working #674

Closed
opened 2026-03-13 07:59:52 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Rakhsan on GitHub (Feb 14, 2025).

The sendOtp function needs to verify the headers to send a otp but after trying to login when redirected to a page that says a otp has been sent to your account and please verify it to login. how the hell would the sendOtp api get the headers? cuz the user doesn't have a session the user is trying to login. The docs says:

const { data, error } = await authClient.twoFactor.sendOtp() if (data) { // redirect or show the user to enter the code }

And also how do I know the user is the actual user. no way to check the user just confirms someone else's code:

const verifyOtp = async (code: string) => { await authClient.twoFactor.verifyOtp({ code }, { onSuccess(){ //redirect the user on success }, onError(ctx){ alert(ctx.error.message) } }) }

IS THERE ANY FIX?

Originally created by @Rakhsan on GitHub (Feb 14, 2025). The sendOtp function needs to verify the headers to send a otp but after trying to login when redirected to a page that says a otp has been sent to your account and please verify it to login. how the hell would the sendOtp api get the headers? cuz the user doesn't have a session the user is trying to login. The docs says: ` const { data, error } = await authClient.twoFactor.sendOtp() if (data) { // redirect or show the user to enter the code } ` And also how do I know the user is the actual user. no way to check the user just confirms someone else's code: ` const verifyOtp = async (code: string) => { await authClient.twoFactor.verifyOtp({ code }, { onSuccess(){ //redirect the user on success }, onError(ctx){ alert(ctx.error.message) } }) } ` **IS THERE ANY FIX?**
Author
Owner

@Bekacru commented on GitHub (Mar 23, 2025):

I couldn't understand what the issue is here. I'm going to close it. Feel free to reopen it if the problem still exists, with a clearer explanation of what you're experiencing.

@Bekacru commented on GitHub (Mar 23, 2025): I couldn't understand what the issue is here. I'm going to close it. Feel free to reopen it if the problem still exists, with a clearer explanation of what you're experiencing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#674