mirror of
https://github.com/documenso/documenso.git
synced 2026-07-27 10:25:00 +10:00
Avoid leaking that a user has an account
This commit is contained in:
@@ -20,7 +20,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(404).json({ message: "No user found with this email" });
|
return res.status(200).json({ message: "A password reset email has been sent." });
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingToken = await prisma.passwordResetToken.findFirst({
|
const existingToken = await prisma.passwordResetToken.findFirst({
|
||||||
@@ -33,7 +33,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (existingToken) {
|
if (existingToken) {
|
||||||
return res.status(400).json({ message: "Password reset requested." });
|
return res.status(200).json({ message: "A password reset email has been sent." });
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = crypto.randomBytes(64).toString("hex");
|
const token = crypto.randomBytes(64).toString("hex");
|
||||||
@@ -55,7 +55,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
|
|
||||||
await sendResetPassword(user, passwordResetToken.token);
|
await sendResetPassword(user, passwordResetToken.token);
|
||||||
|
|
||||||
res.status(200).json({ message: "Password reset email sent." });
|
return res.status(200).json({ message: "A password reset email has been sent." });
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defaultHandler({
|
export default defaultHandler({
|
||||||
|
|||||||
Reference in New Issue
Block a user