Open Muhammed-Rashid-07 opened 1 year ago
the same is happening with me as well!! Did you get how to fix it?
In api > routes > auth.js
Change login request:
`router.post("/login", async (req, res) => { try { const user = await User.findOne({ username: req.body.username });
const hashedPassword = CryptoJS.AES.decrypt(
user.password,
process.env.PASS_SEC
);
const OriginalPassword = hashedPassword.toString(CryptoJS.enc.Utf8);
if (!user || OriginalPassword !== req.body.password) {
res.status(401).json("Błędny login lub hasło użytkownika");
} else {
const accessToken = jwt.sign(
{
id: user._id,
isAdmin: user.isAdmin,
},
process.env.JWT_SEC,
{ expiresIn: "3d" }
);
const { password, ...others } = user._doc;
res.status(200).json({ ...others, accessToken });
}
} catch (err) { res.status(500).json(err); } }); `
Problem is solve here: https://stackoverflow.com/questions/7042340/error-cant-set-headers-after-they-are-sent-to-the-client
Sanj your assign me this possible. I will fix it.
when a user login with wrong password the server is crashing. Can you assign me to fix this issue.