Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

cleanup

Kiran Ka7c7c2f0702c
diff --git a/apps/web/lib/actions/create-new-account.ts b/apps/web/lib/actions/create-new-account.ts
index 5af635f479..743e14fd34 100644
--- a/apps/web/lib/actions/create-new-account.ts
+++ b/apps/web/lib/actions/create-new-account.ts
@@ -1,6 +1,8 @@
"use server";
import { prisma } from "@/lib/prisma";
+import { sendEmail } from "emails";
+import VerifyEmail from "emails/verify-email";
import { flattenValidationErrors } from "next-safe-action";
import { generateOTP } from "../auth";
import { EMAIL_OTP_EXPIRY_IN } from "../auth/constants";
@@ -54,19 +56,16 @@ export const createNewAccountAction = actionClient
});
// Send email with generated OTP
- // await sendEmail({
- // subject: `${process.env.NEXT_PUBLIC_APP_NAME}: OTP to verify your account`,
- // email,
- // react: VerifyEmail({
- // email,
- // code,
- // }),
- // });
+ await sendEmail({
+ subject: `${process.env.NEXT_PUBLIC_APP_NAME}: OTP to verify your account`,
+ email,
+ react: VerifyEmail({
+ email,
+ code,
+ }),
+ });
return {
- user: {
- id: newUser.id,
- email: newUser.email,
- },
+ status: "ok",
};
});
diff --git a/apps/web/lib/zod/schemas/auth.ts b/apps/web/lib/zod/schemas/auth.ts
index 0aaacf9022..ec22bf8468 100644
--- a/apps/web/lib/zod/schemas/auth.ts
+++ b/apps/web/lib/zod/schemas/auth.ts
@@ -8,6 +8,12 @@ export const passwordSchema = z
"Password must contain at least one number, one uppercase, and one lowercase letter",
);
+const emailSchema = z
+ .string()
+ .email()
+ .min(1)
+ .transform((email) => email.toLowerCase());
+
export const resetPasswordSchema = z
.object({
token: z.string().min(1),
@@ -30,16 +36,16 @@ export const updatePasswordSchema = z
});
export const signInSchema = z.object({
- email: z.string().email().min(1),
+ email: emailSchema,
password: z.string().min(1),
});
export const signUpSchema = z.object({
- email: z.string().email(),
+ email: emailSchema,
password: passwordSchema,
});
export const verifyEmailSchema = z.object({
- email: z.string().email().min(1),
+ email: emailSchema,
code: z.string().min(6),
});