#How come the verification code is not confirming is this the correct syntax

16 messages · Page 1 of 1 (latest)

cursive abyss
#

setIsVerifying(true);
const formData = new FormData();

          formData.append("code", values.code);
          formData.append("flow", "email-verification");
          formData.append("email", step.email);
          
          console.log(formData); // Inspect contents properly
          
          await signIn("password", formData);

this is a json of the formData when confirming the email verification

[
[
"code",
"097367"
],
[
"flow",
"email-verification"
],
[
"email",
"[email protected]"
]
]

potent shadowBOT
#

Hi @cursive abyss. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Your syntax for submitting the verification code using signIn("password", formData) with the fields "code", "flow": "email-verification", and "email" matches the documented approach for confirming email verification with the Convex Auth Password provider. The example from the official docs shows the same structure for the verification form:

<form
  onSubmit={(event) => {
    event.preventDefault();
    const formData = new FormData(event.currentTarget);
    void signIn("password", formData);
  }}
>
  <input name="code" placeholder="Code" type="text" />
  <input name="flow" type="hidden" value="email-verification" />
  <input name="email" value={step.email} type="hidden" />
  <button type="submit">Continue</button>
  <button type="button" onClick={() => setStep("signIn")}>
    Cancel
  </button>
</form>

This matches your JSON structure for the FormData object. So, your syntax is correct for the Convex Auth flow for email verification codes Add verification form.

If the verification code is not confirming, possible issues could be:

  • The code is expired or incorrect.
  • The email does not match the one used to request the code.
  • There is a backend misconfiguration or a bug in the provider setup.

You can check the Convex logs for errors like "Invalid verification code" to get more details. Also, ensure that the code and email are exactly as sent in the verification email, and that the backend provider is configured as shown in the docs Provider configuration.

#

If you continue to have issues, double-check that the code is not being used in the wrong flow or that there are no race conditions or duplicate submissions Discord thread: Invalid verification code errors.

In summary: your syntax is correct, but if the code is not confirming, the issue is likely with the code value, email mismatch, or backend configuration.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@cursive abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

cursive abyss
#

import { convexAuth } from "@convex-dev/auth/server";
import CustomProfile from "./CustomProfile";

export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [CustomProfile],
});

import { Password } from "@convex-dev/auth/providers/Password";
import { DataModel } from "./_generated/dataModel";
import { ResendOTPPasswordReset } from "./ResendOTPPasswordReset";
import { ResendOTP } from "./ResendOTP";

export default Password<DataModel>({
reset: ResendOTPPasswordReset,
verify: ResendOTP,
profile(params) {
return {
email: params.email as string,
name: params.name as string,
role: params.role as string,
isAdmin: params.isAdmin === "true" || params.isAdmin === true,
updates: params.updates === "true" || params.updates === true,
title: params.title as string,
};
},
});

could you check if there is a bug in my provider setup

#

@potent shadow

potent shadowBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

Sorry @cursive abyss, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:

Perhaps try again in 15mins?

cursive abyss
#

import { convexAuth } from "@convex-dev/auth/server";
import CustomProfile from "./CustomProfile";

export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [CustomProfile],
});

import { Password } from "@convex-dev/auth/providers/Password";
import { DataModel } from "./_generated/dataModel";
import { ResendOTPPasswordReset } from "./ResendOTPPasswordReset";
import { ResendOTP } from "./ResendOTP";

export default Password<DataModel>({
reset: ResendOTPPasswordReset,
verify: ResendOTP,
profile(params) {
return {
email: params.email as string,
name: params.name as string,
role: params.role as string,
isAdmin: params.isAdmin === "true" || params.isAdmin === true,
updates: params.updates === "true" || params.updates === true,
title: params.title as string,
};
},
});

could you check if there is a bug in my provider setup @potent shadow

potent shadowBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

Based on the knowledge sources, your provider setup for a custom Password provider with Convex Auth appears to follow the documented approach for customizing the user profile and integrating custom email verification and password reset providers.

Key points from your setup:

  • You are using Password<DataModel>({...}) with custom reset and verify providers, which is correct for enabling custom flows for password reset and email verification (PasswordConfig<DataModel> docs).
  • The profile(params) function is used to map incoming params to your user schema, which is the intended use (PasswordConfig<DataModel> docs).
  • You are returning all expected fields in the profile, and your boolean conversions for isAdmin and updates are reasonable.

Potential issues to check:

  1. Type Safety:
    Make sure your DataModel's users table matches the fields you return in profile. If, for example, role, isAdmin, updates, or title are not present or have different types in your schema, you may encounter issues during user creation or updates.

  2. Email Field:
    The email field should be present and required in your users table schema, as Convex Auth expects to use it for verification and identification.

#
  1. Custom Callback:
    If you are using a custom createOrUpdateUser callback in convexAuth, you are responsible for correctly handling all fields and updating the verification fields (like emailVerificationTime) as needed. The knowledge sources warn that writing a custom callback is tricky and you must ensure you are doing everything required by Convex Auth (Discord: custom user schema).

  2. Provider IDs:
    If you use multiple providers (e.g., for multilingual support), ensure each has a unique id (PasswordConfig<DataModel> docs).

Summary:
Your provider setup matches the documented approach for custom user profiles and custom email flows. The main things to double-check are your users table schema and any custom user creation logic. If you are seeing issues, they are likely related to schema mismatches or custom callback logic, not the provider setup itself.

If you have a specific error or issue, please provide the error message or describe the behavior for more targeted help.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@cursive abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

opaque patrol
#

Could you provide your CustomProfile