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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user