Expire token after 1 hour

This commit is contained in:
Ephraim Atta-Duncan
2023-06-05 16:54:12 +00:00
parent 2b9a2ff250
commit 3a0648c85d
6 changed files with 25 additions and 23 deletions

View File

@ -25,12 +25,16 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
return res.status(404).json({ message: "Invalid token." });
}
const now = new Date();
if (now > foundToken.expiry) {
return res.status(400).json({ message: "Token has expired" });
}
const isSamePassword = await verifyPassword(password, foundToken.User.password!);
if (isSamePassword) {
return res
.status(400)
.json({ message: "New password must be different from the current password." });
return res.status(400).json({ message: "New password must be different" });
}
const hashedPassword = await hashPassword(password);