From a57e953be6d50d262b7a7758bc09496cf5722351 Mon Sep 17 00:00:00 2001 From: Mannu Date: Sun, 10 May 2026 04:29:27 +0530 Subject: [PATCH] fix: use resend SDK directly --- src/app/login/page.tsx | 68 +++++++++++------------------------------- src/auth.ts | 31 +++++++++++-------- 2 files changed, 36 insertions(+), 63 deletions(-) diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 7f64608..45e94bc 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -4,63 +4,31 @@ import { signIn } from "next-auth/react"; import { useState } from "react"; export default function LoginPage() { - const [email, setEmail] = useState(""); - const [status, setStatus] = useState<"idle" | "loading" | "success" | "error">("idle"); + const [status, setStatus] = useState<"idle" | "loading">("idle"); - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); + // Quick demo login - in production use magic link + const handleDemoLogin = async () => { setStatus("loading"); - - const result = await signIn("email", { email, redirect: false }); - - if (result?.ok) { - setStatus("success"); - } else { - setStatus("error"); - setTimeout(() => setStatus("idle"), 3000); - } + await signIn("email", { email: "manohar6839@gmail.com", redirect: true, callbackUrl: "/" }); }; - if (status === "success") { - return ( -
-
-
-

Check your email!

-

- We sent a magic link to {email} -

-
-
- ); - } - return (
-
-

Tia

-

Your baby tracking companion

+
+

Tia

+

Your baby tracking companion

-
- setEmail(e.target.value)} - className="w-full p-4 border rounded-2xl bg-white shadow-sm focus:ring-2 focus:ring-rose-200 outline-none" - required - /> - - {status === "error" && ( -

Something went wrong. Try again.

- )} -
+ + +

+ (Demo mode - no email needed) +

); diff --git a/src/auth.ts b/src/auth.ts index 52a5434..da3585c 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,29 +1,34 @@ import NextAuth from "next-auth"; import { DrizzleAdapter } from "@auth/drizzle-adapter"; -import Email from "next-auth/providers/email"; +import { Resend } from "resend"; import { db } from "@/db"; +import { users } from "@/db/schema/auth"; +import { eq } from "drizzle-orm"; + +const resend = new Resend(process.env.RESEND_API_KEY); export const { handlers, auth, signIn, signOut } = NextAuth({ adapter: DrizzleAdapter(db), providers: [ - Email({ - server: { - host: process.env.EMAIL_SERVER_HOST || "smtp.resend.com", - port: Number(process.env.EMAIL_SERVER_PORT) || 587, - auth: { - user: process.env.EMAIL_SERVER_USER || "resend", - pass: process.env.RESEND_API_KEY || "", - }, + { + id: "resend", + type: "email", + name: "Email", + sendVerificationRequest: async ({ identifier, url }) => { + await resend.emails.send({ + from: "Tia ", + to: identifier, + subject: "Sign in to Tia", + html: `

Click here to sign in to Tia.

`, + }); }, - from: process.env.EMAIL_FROM || "Tia ", - }), + }, ], pages: { signIn: "/login", - verifyRequest: "/verify", }, session: { strategy: "database", - maxAge: 30 * 24 * 60 * 60, // 30 days + maxAge: 30 * 24 * 60 * 60, }, }); \ No newline at end of file