Docs: Incorrect HTTP status code for unverified email error, 403 (docs) vs 401 (actual) #525

Closed
opened 2026-03-13 07:50:58 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @powdaze on GitHub (Jan 4, 2025).

In the docs for email and password, it is mentioned that:

If a user tries to sign in without verifying their email, you can handle the error and show a message to the user.

await authClient.signIn.emailAndPassword(
  {
    email: "email@example.com",
    password: "password",
  },
  {
    onError: (ctx) => {
      // Handle the error
      if (ctx.error.status === 403) {
        alert("Please verify your email address");
      }
      //you can also show the original error message
      alert(ctx.error.message);
    },
  }
);

However, when attempting to sign in with an unverified email, the error code is actually 401, not 403

{
    "message": "Email not verified",
    "code": "EMAIL_NOT_VERIFIED",
    "status": 401,
    "statusText": "UNAUTHORIZED"
}
Originally created by @powdaze on GitHub (Jan 4, 2025). In the [docs for email and password](https://www.better-auth.com/docs/authentication/email-password), it is mentioned that: >If a user tries to sign in without verifying their email, you can handle the error and show a message to the user. ```ts await authClient.signIn.emailAndPassword( { email: "email@example.com", password: "password", }, { onError: (ctx) => { // Handle the error if (ctx.error.status === 403) { alert("Please verify your email address"); } //you can also show the original error message alert(ctx.error.message); }, } ); ``` However, when attempting to sign in with an unverified email, the error code is actually 401, not 403 ```ts { "message": "Email not verified", "code": "EMAIL_NOT_VERIFIED", "status": 401, "statusText": "UNAUTHORIZED" } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#525