This is what shown on my websocket
{type: "AuthError", error: "No auth provider found matching the given token", baseVersion: 0}
This is how I do the login
const { signIn } = useAuthActions();
Then
const form = new FormData();
form.set("email", email);
await signIn("resend-otp", form);
and
form.set("email", email);
form.set("code", otp);
try {
const result = await signIn("resend-otp", form);
console.log("result", result);
} catch (error) {
console.error(error);
and here is the backend set up
resendOtp.ts
import { Email } from "@convex-dev/auth/providers/Email";
import { alphabet, generateRandomString } from "oslo/crypto";
import { Resend as ResendAPI } from "resend";
export const ResendOtp = Email({
id: "resend-otp",
apiKey: process.env.AUTH_RESEND_KEY,
maxAge: 15 * 60,
async generateVerificationToken() {
return generateRandomString(8, alphabet("0-9"));
},
async sendVerificationRequest({ identifier: email, provider, token }) {
const resend = new ResendAPI(provider.apiKey);
const { error } = await resend.emails.send({
from: "no-reply <no-reply@atthe.club>",
to: [email],
subject: "Your one-time password",
text: `Your one-time password is ${token}`,
});
if (error) {
throw new Error(error.message);
}
},
});
import { convexAuth } from "@convex-dev/auth/server";
import { ResendOtp } from "./resendOtp";
export const { auth, signIn, signOut, store } = convexAuth({
providers: [ResendOtp],
});