added email env variable

This commit is contained in:
Polaris 2024-08-16 21:46:43 -04:00
parent 4186a110cf
commit 4f728b8c4e
2 changed files with 6 additions and 8 deletions

View File

@ -8,11 +8,12 @@ import { redirect } from "next/navigation";
const resend = new Resend(process.env.NEXT_PUBLIC_RESEND_API_KEY);
const DOMAIN = process.env.DOMAIN || "localhost:3000";
const PROTOCOL = process.env.NODE_ENV === "production" ? "https" : "http";
const EMAIL = process.env.EMAIL || "<security@resend.dev>";
const sendEmail = async (email: string, token: string, userName: string) => {
try {
const { data } = await resend.emails.send({
from: "Password Reset <security@resend.dev>",
from: `Password Reset ${EMAIL}`,
to: [email],
subject: "Reset Password Request",
text: `Hello ${userName}, someone (hopefully you) requested a password reset for this account. If you did want to reset your password, please click here: ${PROTOCOL}://${DOMAIN}/password-reset/${token}

View File

@ -17,8 +17,8 @@ export default function ForgotPassword() {
};
return (
<main className="max-w-xl px-4 mx-auto flex flex-col justify-center h-screen ">
<Card className="gap-4 flex flex-col p-6 ">
<main className="mx-auto flex h-screen max-w-xl flex-col justify-center px-4">
<Card className="flex flex-col gap-4 p-6">
<form action={submit} className="flex flex-col gap-4">
{" "}
<h1 className="text-2xl font-light">Reset password</h1>
@ -29,12 +29,9 @@ export default function ForgotPassword() {
<Input name="email" type="email" placeholder="Your email..." />
{error && <p className="text-red-500">{error}</p>}
<Button type="submit">Reset Password</Button>
<Link
href="/"
className="text-sm text-neutral-700/80 flex items-center"
>
<Link href="/" className="flex items-center text-sm">
<ArrowLeftSquare />
<span>Return to Login</span>
<span className="pl-2">Return to Login</span>
</Link>
</form>
</Card>