diff --git a/server/index.js b/server/index.js index eed1ae9..e722bf6 100644 --- a/server/index.js +++ b/server/index.js @@ -1276,7 +1276,15 @@ const server = http.createServer(async (req, res) => { const kayit = store.getUser(user.email); const subId = kayit?.stripe_sub_id; if (!subId) return json(res, 400, { success: false, error: 'Aktif bir aboneliğiniz görünmüyor.' }); - const body = await readJson(req); + let body; + try { + body = await readBody(req); + if (!body || typeof body !== 'object' || Array.isArray(body)) throw new Error('Geçersiz abonelik iptal gövdesi.'); + if (body.neden != null && (typeof body.neden !== 'string' || body.neden.length > 100)) throw new Error('İptal nedeni geçersiz.'); + if (body.aciklama != null && (typeof body.aciklama !== 'string' || body.aciklama.length > 500)) throw new Error('İptal açıklaması geçersiz.'); + } catch (error) { + return json(res, 400, { success: false, error: error.message }); + } try { const out = await cancelSubscription({ subId, neden: body.neden, aciklama: body.aciklama }); // Neden kaydı: ürün kararları için kendi tarafımızda da tutulur.