is a passwordless sign-up/sign-in possible?
im trying to roll out passwordless login with email otp (similar to that of supabase), which can sign up users if they don't exist in the db or sign in, however im getting the following error:
^^^ the verification table exists in my db with the exact schema generated by the cli (check image)
my auth config:
btw im using trpc:
TRPCClientError: [# Drizzle Adapter]: The model "verification" was not found in the schema object. Please pass the schema directly to the adapter options.TRPCClientError: [# Drizzle Adapter]: The model "verification" was not found in the schema object. Please pass the schema directly to the adapter options.^^^ the verification table exists in my db with the exact schema generated by the cli (check image)
my auth config:
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { emailOTP } from "better-auth/plugins";
import { env } from "~/env";
import { db } from "~/server/db";
export const auth = betterAuth({
database: drizzleAdapter(db, { provider: "sqlite" }),
emailAndPassword: {
enabled: false,
disableSignUp: true,
autoSignIn: true,
},
plugins: [
emailOTP({
sendVerificationOTP: async ({ email, otp }) => {
console.log(email, otp);
},
}),
],
user: {
additionalFields: {
username: {
type: "string",
unique: true,
required: false,
},
},
},
secret: env.AUTH_SECRET,
baseURL: env.NEXT_PUBLIC_BASE_URL,
});import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { emailOTP } from "better-auth/plugins";
import { env } from "~/env";
import { db } from "~/server/db";
export const auth = betterAuth({
database: drizzleAdapter(db, { provider: "sqlite" }),
emailAndPassword: {
enabled: false,
disableSignUp: true,
autoSignIn: true,
},
plugins: [
emailOTP({
sendVerificationOTP: async ({ email, otp }) => {
console.log(email, otp);
},
}),
],
user: {
additionalFields: {
username: {
type: "string",
unique: true,
required: false,
},
},
},
secret: env.AUTH_SECRET,
baseURL: env.NEXT_PUBLIC_BASE_URL,
});btw im using trpc:
export const authRouter = createTRPCRouter({
isAuthenticated: publicProcedure.query(
async () => await auth.api.getSession({ headers: await headers() }),
),
sendOTP: publicProcedure
.input(z.object({ email: z.string().email() }))
.mutation(
async ({ input: { email } }) =>
await auth.api.sendVerificationOTP({
body: { email, type: "sign-in" },
}),
),
login: publicProcedure
.input(
z.object({ email: z.string().email(), otp: z.string().min(6).max(6) }),
)
.mutation(
async ({ input: { email, otp } }) =>
await auth.api.signInEmailOTP({ body: { email, otp } }),
),
});export const authRouter = createTRPCRouter({
isAuthenticated: publicProcedure.query(
async () => await auth.api.getSession({ headers: await headers() }),
),
sendOTP: publicProcedure
.input(z.object({ email: z.string().email() }))
.mutation(
async ({ input: { email } }) =>
await auth.api.sendVerificationOTP({
body: { email, type: "sign-in" },
}),
),
login: publicProcedure
.input(
z.object({ email: z.string().email(), otp: z.string().min(6).max(6) }),
)
.mutation(
async ({ input: { email, otp } }) =>
await auth.api.signInEmailOTP({ body: { email, otp } }),
),
});