[GH-ISSUE #516] phoneNumber.verify() isn't working as expected #8303

Closed
opened 2026-04-13 03:22:40 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @ywyher on GitHub (Nov 13, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/516

I'm using the phoneNumber and then send OTP to verify the phone number:

OTP Sent with phoneNumber.sendOtp().
If the OTP is incorrect, I receive an "Invalid OTP" error message in the console, which is expected.
If the OTP is correct, however, the verification code record is deleted from the database, and an error is thrown: phone number not found. This prevents further actions on success, like user creation.

Current Workaround:
To bypass this issue, I'm using the signUpOnVerification option within the phoneNumber plugin. This does create a user, but only with the name and email fields. Unfortunately, there’s no customization option, so I can't populate other fields (e.g., username, custom attributes).

    const result = await phoneNumber.verify({
        phoneNumber: 'phoneNumber',
        code: 'code'
    })

    if(result.error) {
        // this is always the case even if the code is correct
        console.error(result.error.message)
    }else {
        // never gets called
        console.log('working')
    }
  • OS: Arch linux
  • Browser: firefox
  • Version 8.02
Originally created by @ywyher on GitHub (Nov 13, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/516 I'm using the phoneNumber and then send OTP to verify the phone number: OTP Sent with phoneNumber.sendOtp(). If the OTP is incorrect, I receive an "Invalid OTP" error message in the console, which is expected. If the OTP is correct, however, the verification code record is deleted from the database, and an error is thrown: phone number not found. This prevents further actions on success, like user creation. **Current Workaround:** To bypass this issue, I'm using the signUpOnVerification option within the phoneNumber plugin. This does create a user, but only with the name and email fields. Unfortunately, there’s no customization option, so I can't populate other fields (e.g., username, custom attributes). ```tsx const result = await phoneNumber.verify({ phoneNumber: 'phoneNumber', code: 'code' }) if(result.error) { // this is always the case even if the code is correct console.error(result.error.message) }else { // never gets called console.log('working') } ``` - OS: Arch linux - Browser: firefox - Version 8.02
GiteaMirror added the locked label 2026-04-13 03:22:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8303