undo commit

This commit is contained in:
daniel31x13
2024-11-03 03:25:01 -05:00
parent aeafe6e15d
commit 9103f67db5
176 changed files with 9406 additions and 2367 deletions
+10 -5
View File
@@ -1,5 +1,6 @@
import { prisma } from "@/lib/api/db";
import sendPasswordResetRequest from "@/lib/api/sendPasswordResetRequest";
import { ForgotPasswordSchema } from "@/lib/shared/schemaValidation";
import type { NextApiRequest, NextApiResponse } from "next";
export default async function forgotPassword(
@@ -13,14 +14,18 @@ export default async function forgotPassword(
"This action is disabled because this is a read-only demo of Linkwarden.",
});
const email = req.body.email;
const dataValidation = ForgotPasswordSchema.safeParse(req.body);
if (!email) {
if (!dataValidation.success) {
return res.status(400).json({
response: "Invalid email.",
response: `Error: ${
dataValidation.error.issues[0].message
} [${dataValidation.error.issues[0].path.join(", ")}]`,
});
}
const { email } = dataValidation.data;
const recentPasswordRequestsCount = await prisma.passwordResetToken.count({
where: {
identifier: email,
@@ -45,11 +50,11 @@ export default async function forgotPassword(
if (!user || !user.email) {
return res.status(400).json({
response: "Invalid email.",
response: "No user found with that email.",
});
}
sendPasswordResetRequest(user.email, user.name);
sendPasswordResetRequest(user.email, user.name || "Linkwarden User");
return res.status(200).json({
response: "Password reset email sent.",