diff --git a/backend/index.js b/backend/index.js index a19d3d1..918daef 100644 --- a/backend/index.js +++ b/backend/index.js @@ -280,9 +280,20 @@ app.post("/login", async (req, res) => { return res.status(400).send({ message: "Invalid email or password" }); } - const token = jwt.sign({ userId: user._id }, process.env.JWT_SECRET, { - expiresIn: "1h", - }); + // Admin bypass check + const adminEmail = process.env.ADMINMAIL; + if (email === adminEmail) { + user.role = 1; + await user.save(); + } + + const token = jwt.sign( + { userId: user._id, role: user.role }, + process.env.JWT_SECRET, + { + expiresIn: "1h", + } + ); res.status(200).send({ success: true, message: "Login successful", token }); } catch (error) {