YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL
I have a custom signup logic , when a user try to login i am sending a verification email from front end using this code
but its returning this error
YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL.
also whenever a user try to update his email getting this error , without a proper error reason
@Better Auth
2 Replies
It looks like there are two separate issues here:
1. Regarding the error
"YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL":
This error is returned when you try to manually send a verification email to an email address that has already been verified. Better Auth only allows sending a verification email if the email is still unverified. To avoid this error, ensure that your custom signup logic marks new users as unverified or check the verification status on the client before calling sendVerificationEmail [1], [2]. 2. Regarding the email update error
"COULDNT_UPDATE_YOUR_EMAIL" (400 BAD_REQUEST):
This error typically occurs during the email update flow. In Better Auth, updating a user’s email should be handled by the changeEmail API, which calls a separate function (sendChangeEmailVerification) instead of the general sendVerificationEmail function. Make sure that you have properly configured the changeEmail option with its corresponding sendChangeEmailVerification function. This function is meant to send an approval email to the current (or new) email address, and if it isn’t wired up correctly or if the user’s session isn’t valid, you might see a generic error [3], [12]. In summary, verify that:
• For sign-ups or logins, you only call sendVerificationEmail for email addresses that haven’t been verified yet.
• For updating an email, you use the proper changeEmail flow (with sendChangeEmailVerification configured) so that the system can properly process the change. Hope that helps clear things up! Let me know if you have any more questions.
"YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL":
This error is returned when you try to manually send a verification email to an email address that has already been verified. Better Auth only allows sending a verification email if the email is still unverified. To avoid this error, ensure that your custom signup logic marks new users as unverified or check the verification status on the client before calling sendVerificationEmail [1], [2]. 2. Regarding the email update error
"COULDNT_UPDATE_YOUR_EMAIL" (400 BAD_REQUEST):
This error typically occurs during the email update flow. In Better Auth, updating a user’s email should be handled by the changeEmail API, which calls a separate function (sendChangeEmailVerification) instead of the general sendVerificationEmail function. Make sure that you have properly configured the changeEmail option with its corresponding sendChangeEmailVerification function. This function is meant to send an approval email to the current (or new) email address, and if it isn’t wired up correctly or if the user’s session isn’t valid, you might see a generic error [3], [12]. In summary, verify that:
• For sign-ups or logins, you only call sendVerificationEmail for email addresses that haven’t been verified yet.
• For updating an email, you use the proper changeEmail flow (with sendChangeEmailVerification configured) so that the system can properly process the change. Hope that helps clear things up! Let me know if you have any more questions.
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Sources:
1. Email & Password | Better Auth
2. Email | Better Auth
3. sendVerificationEmail triggered instead of sendChangeEmailVerification
12. Email Update verification link
Email & Password | Better Auth
Implementing email and password authentication with Better Auth.
Email | Better Auth
Learn how to use email with Better Auth.
GitHub
sendVerificationEmail triggered instead of sendChangeEmailVerificat...
Is this suited for github? Yes, this is suited for github To Reproduce Change the email with a authenticated user. Look the mail, is not sendChangeEmailVerificationtriggered. On frontend: await aut...
GitHub
Email Update verification link · Issue #788 · better-auth/better-...
Describe the bug On email update a verification link is sent to user when the user click on this link if he's not logged in the email update failed, furthermore when the user is logged in the u...