feat: latest updates
This commit is contained in:
parent
8e3d2ac02b
commit
1a6eaa5a0e
@ -177,10 +177,24 @@ router.put(
|
||||
db.get("SELECT * FROM reports WHERE id = ?", [reportId], (err, report) => {
|
||||
if (err || !report)
|
||||
return res.status(404).json({ error: "Report not found" });
|
||||
// Not admin & not owner
|
||||
if (req.user.role !== "admin" && report.userId !== req.user.userId) {
|
||||
return res.status(403).json({ error: "Forbidden" });
|
||||
}
|
||||
|
||||
// Not admin & trying to edit a verified report
|
||||
if (
|
||||
req.user.role !== "admin" &&
|
||||
(report.isVerified === 1 ||
|
||||
report.isVerified === true ||
|
||||
report.verified === 1 ||
|
||||
report.verified === true)
|
||||
) {
|
||||
return res
|
||||
.status(403)
|
||||
.json({ error: "Запрещено редактировать подтвержденный отчет" });
|
||||
}
|
||||
|
||||
const fields = [];
|
||||
const values = [];
|
||||
for (const key of [
|
||||
|
Loading…
Reference in New Issue
Block a user