const LESSON_REPORT_EDIT_DENIED = 'Изменять отчёт о занятии может только его автор или администратор'; function lessonReportEditable(report, user) { if (!report || !user) return false; if (user.role === 'admin') return true; if (report.author_id == null) return false; return Number(report.author_id) === Number(user.id); } function lessonReportWriteBlocked(res, report, user) { if (lessonReportEditable(report, user)) return false; res.status(403).json({ error: LESSON_REPORT_EDIT_DENIED }); return true; } module.exports = { LESSON_REPORT_EDIT_DENIED, lessonReportEditable, lessonReportWriteBlocked };