fix: allow case-less ("general") chat without ownership check

requireAuth treated every chat caseId as a real cases row and rejected
"general" (the no-file chat sentinel) with 403. general chat now skips
the ownership check and is answered without touching chat_messages,
since that table's case_id is a NOT NULL FK to cases.
This commit is contained in:
mstfyldz
2026-08-09 01:52:53 +03:00
parent afbfb413ce
commit b030bdaa60
2 changed files with 37 additions and 1 deletions
+3 -1
View File
@@ -33,8 +33,10 @@ export const requireAuth = async (req: AuthenticatedRequest, res: Response, next
req.user = user;
// P0-3: Kaynak Sahipliği Doğrulama (Eğer istekte caseId veya case_id varsa)
// "general", dosyasız/genel sohbet için ayrılmış bir sentinel değer — gerçek bir
// case kaydı değil, bu yüzden sahiplik kontrolüne tabi tutulmaz.
const caseId = req.params.caseId || req.body?.case_id;
if (caseId) {
if (caseId && caseId !== 'general') {
const { data: caseRecord, error: caseError } = await supabase
.from('cases')
.select('id')