Skip to content

Commit

Permalink
fix: stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Nov 20, 2023
1 parent 65f5efb commit 3358e96
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions api/src/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ router.get(

router.post(
"/forgot_password",
catchErrors(async ({ body: { email } }, res) => {
catchErrors(async (req, res) => {
const {
body: { email },
} = req;
try {
z.string()
.email()
Expand All @@ -269,9 +272,8 @@ router.post(
}

UserLog.create({
user: email,
platform: req.headers.platform === "android" ? "app" : req.headers.platform === "dashboard" ? "dashboard" : "unknown",
action: "forgot-password",
action: `forgot-password-${email}`,
});

if (!email) return res.status(403).send({ ok: false, error: "Veuillez fournir un email", code: EMAIL_OR_PASSWORD_INVALID });
Expand Down Expand Up @@ -323,9 +325,8 @@ router.post(

if (!user) {
UserLog.create({
user: token,
platform: req.headers.platform === "android" ? "app" : req.headers.platform === "dashboard" ? "dashboard" : "unknown",
action: "forgot-password-reset-failed",
action: `forgot-password-reset-failed-${token}`,
});
return res.status(400).send({ ok: false, error: "Le lien est non valide ou expiré" });
}
Expand Down

0 comments on commit 3358e96

Please sign in to comment.