Remove email parameter from resendOtpHelper and normalize email addresses to lowercase in the resend OTP handler for consistent processing.

This commit is contained in:
2025-12-08 15:25:21 +05:30
parent d5d6951e64
commit 1a520ae9e1
2 changed files with 3 additions and 3 deletions

View File

@@ -12,7 +12,6 @@ export interface OtpResult {
export async function resendOtpHelper(
prisma: any,
userId: number,
email: string,
emailPurpose: "Register" | "Login" | "ForgotPassword",
otpLength: 4 | 6 = 4,
expiryMinutes: number = 5

View File

@@ -41,9 +41,11 @@ export const handler = safeHandler(
const email = (body.email || "").trim();
if (!email) throw new ApiError(400, "Email is required");
const emailToLowerCase = email.toLowerCase();
// find user (you can adapt the isActive / userStatus checks per your rules)
const user = await prisma.user.findUnique({
where: { emailAddress: email, isActive: true },
where: { emailAddress: emailToLowerCase, isActive: true },
select: { id: true, emailAddress: true, role: true },
});
@@ -56,7 +58,6 @@ export const handler = safeHandler(
const otpResult = await resendOtpHelper(
prisma,
user.id,
user.emailAddress,
purpose,
6, // 6-digit OTP
5 // expires in 5 minutes